mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-21 17:12:32 +00:00
fix(signal): raise on signal-cli error response so send is retriable
_send_http_request collapses every exception path into a {"error": ...}
dict, so the if "error" in response branch inside send() is the only
place where send failures surface. Logging-only there meant the
ChannelManager retry mechanism never fired. Raise RuntimeError so the
base-class retry path is exercised; the outer try/except already
re-raises into the caller.
Addresses review comment on PR #3852.
This commit is contained in:
parent
aed6b6967c
commit
2d81cc0ae1
@ -506,6 +506,7 @@ class SignalChannel(BaseChannel):
|
||||
|
||||
if "error" in response:
|
||||
self.logger.error(f"Error sending Signal message: {response['error']}")
|
||||
raise RuntimeError(f"signal-cli send failed: {response['error']}")
|
||||
else:
|
||||
self.logger.debug(
|
||||
f"Signal message sent, timestamp: {response.get('result', {}).get('timestamp')}"
|
||||
|
||||
@ -1217,13 +1217,14 @@ class TestSend:
|
||||
assert "+19995550001" in stopped
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_send_logs_daemon_error_without_raising(self):
|
||||
async def test_send_raises_on_daemon_error(self):
|
||||
# _send_http_request turns every exception into {"error": ...}, so this branch
|
||||
# is the only place ChannelManager retry can be triggered — must raise.
|
||||
ch = _make_channel()
|
||||
# The daemon returns {"error": {...}} in the JSON body — this is not a Python
|
||||
# exception; send() logs it but does not raise (only HTTP-level exceptions raise).
|
||||
ch._http = _FakeHTTPClient(default_response={"error": {"message": "fail"}})
|
||||
msg = OutboundMessage(channel="signal", chat_id="+19995550001", content="hello")
|
||||
await ch.send(msg) # must not raise
|
||||
with pytest.raises(RuntimeError, match="signal-cli send failed"):
|
||||
await ch.send(msg)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user