From a033bb3df1789b1d773c687ae95d184a64dccd8b Mon Sep 17 00:00:00 2001 From: Jah-yee <166608075+Jah-yee@users.noreply.github.com> Date: Sat, 26 Sep 2026 09:28:13 +0800 Subject: [PATCH] fix: raise RuntimeError on empty Discord body instead of IndexError When a Discord reply body is empty (blank), chatformat.split returns no pieces, causing 'sent[0]' to raise IndexError. Now raises RuntimeError('nothing to send') when body is empty, consistent with other refusal patterns in this file. Fixes: https://github.com/ldbumble/taskuary/issues/66 --- taskuary/outbound.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/taskuary/outbound.py b/taskuary/outbound.py index a4132b26..fac5b7af 100644 --- a/taskuary/outbound.py +++ b/taskuary/outbound.py @@ -610,6 +610,8 @@ def reply_to_message(store, msg: dict, body: str, to: list = None, cc: list = No if not chat: raise RuntimeError('this chat message has no channel id to answer in') connector_id = _source_connector_id(store, 'discord', chat) pieces = chatformat.split(body, 1900) + if not pieces: + raise RuntimeError("nothing to send") sent = [discord_send(store, chat, piece, connector_id) if connector_id else discord_send(store, chat, piece) for piece in pieces] return sent[0]