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:
Kaloyan Tenchov 2026-05-19 08:56:06 -04:00 committed by chengyongru
parent aed6b6967c
commit 2d81cc0ae1
2 changed files with 6 additions and 4 deletions

View File

@ -506,6 +506,7 @@ class SignalChannel(BaseChannel):
if "error" in response: if "error" in response:
self.logger.error(f"Error sending Signal message: {response['error']}") self.logger.error(f"Error sending Signal message: {response['error']}")
raise RuntimeError(f"signal-cli send failed: {response['error']}")
else: else:
self.logger.debug( self.logger.debug(
f"Signal message sent, timestamp: {response.get('result', {}).get('timestamp')}" f"Signal message sent, timestamp: {response.get('result', {}).get('timestamp')}"

View File

@ -1217,13 +1217,14 @@ class TestSend:
assert "+19995550001" in stopped assert "+19995550001" in stopped
@pytest.mark.asyncio @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() 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"}}) ch._http = _FakeHTTPClient(default_response={"error": {"message": "fail"}})
msg = OutboundMessage(channel="signal", chat_id="+19995550001", content="hello") 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)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------