Auto: fix/streaming-message-too-long #17
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/streaming-message-too-long"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Automated PR for branch
fix/streaming-message-too-long.Changes Requested
Well-structured change — the refactoring from closure to stateful class is clean and the test coverage is solid. One real bug: the continuation message leaks on error paths.
Warnings
not result.success) before the cleanup block at line 906. If streaming sent the 'Tarjima davom etmoqda...' message but the translation then fails, the user is left with a stale continuation message in the chat. Move the cleanup before the two early-return blocks, or extract a small helper and call it in all three paths.Suggestions
_handle_message_too_long(self, accumulated_text)acceptsaccumulated_textbut never uses it. Consider removing the parameter to avoid confusion (callers may think it's being sent to Telegram).Approved
Clean, well-structured change. The refactoring from a closure to a
_StreamingCallbackclass is appropriate for managing the continuation message state. Error handling flows are correct: the callback catchesmessage_too_long, sends the continuation indicator, re-raises for the streaming loop to disable further edits, and cleanup runs in all code paths. The finaltranslate_messagealready usessplit_message()for the formatted result, so messages exceeding 4096 chars are handled end-to-end. Test coverage is solid.Suggestions
context.bot.delete_messageas anAsyncMock. It works because_delete_continuation_messagehas a broadexcept Exception: passthat swallows theTypeErrorfrom awaiting a regularMagicMock, while the call is still recorded for assertion. Addingcontext.bot.delete_message = AsyncMock()would make the test more explicit and less reliant on this incidental behavior.