fix: publish error event on invalid conversation/message in chatflow SSE#37244
Open
1795771535y-cell wants to merge 3 commits into
Open
fix: publish error event on invalid conversation/message in chatflow SSE#372441795771535y-cell wants to merge 3 commits into
1795771535y-cell wants to merge 3 commits into
Conversation
…tening elements When _truncate_array breaks due to size limit exceeding target_size, the truncated flag was not set to True, causing dropped tail elements to go unreported. Additionally, the flag was overwritten (truncated = part_result.truncated) instead of accumulated, so a later fitting element could reset a previously-set flag to False. Fix by setting truncated = True before the size-limit break, and using logical OR to accumulate (truncated = truncated or part_result.truncated). Fixes langgenius#37192 Signed-off-by: C4P-T <cap@teamos.dev>
…view
The /files/{id}/file-preview endpoint unconditionally set Content-Type to
application/octet-stream after the Response constructor had already used
the correct upload_file.mime_type, causing all inline previews (images,
PDFs, etc.) to be forced as downloads instead of rendering in-browser.
Move the octet-stream override inside the as_attachment branch so it
only applies when the caller explicitly requests download-as-attachment.
For normal previews, the original mime_type from the Response constructor
is preserved.
Fixes langgenius#37198
Signed-off-by: C4P-T <cap@teamos.dev>
The _generate_worker in AdvancedChatAppGenerator called _get_conversation and _get_message BEFORE the try/except block that handles errors and publishes them to the SSE queue. When the conversation_id or message_id is invalid (e.g., non-existing), ConversationNotExistsError or MessageNotExistsError crashes the worker thread silently, leaving the SSE stream hanging with only ping events. Wrap the conversation/message fetch in a try/except that publishes the error via queue_manager.publish_error, consistent with how chat/app_generator and agent_chat/app_generator already handle these errors. Fixes langgenius#37197 Signed-off-by: C4P-T <cap@teamos.dev>
Contributor
Pyrefly Type Coverage
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #37197
When sending a chat-messages request with a non-existing conversation_id to a chatflow (advanced-chat) app, the SSE stream opens but only ping/keepalive events are received - the request never completes and no error is returned.
Root Cause
In AdvancedChatAppGenerator._generate_worker, the conversation and message lookup (lines 619-620) was placed BEFORE the try/except block that catches errors and publishes them to the SSE queue:
`python
conversation = self._get_conversation(conversation_id) # raises ConversationNotExistsError
message = self._get_message(message_id)
... later ...
try:
runner.run()
except ...:
queue_manager.publish_error(...)
`
When ConversationNotExistsError or MessageNotExistsError is raised, the worker thread crashes silently without publishing an error event. The main SSE stream loop continues waiting on the queue manager, sending only periodic pings.
Fix
Wrap the conversation/message fetch in a try/except that publishes the error via queue_manager.publish_error(e, PublishFrom.APPLICATION_MANAGER). This is consistent with how chat/app_generator and agent_chat/app_generator already handle this - both have the _get_conversation call inside their try/except blocks.
python try: conversation = self._get_conversation(conversation_id) message = self._get_message(message_id) except (ConversationNotExistsError, MessageNotExistsError) as e: queue_manager.publish_error(e, PublishFrom.APPLICATION_MANAGER) returnBehavior After Fix
Invalid conversation_id -> SSE error event: {"event": "error", "message": "Conversation not exists", "status": 500}