fix: resolve fresh deploy broken chat — missing flows and UnboundLocalError (#1229)#1241
Open
NPuhlmann wants to merge 2 commits intolangflow-ai:mainfrom
Open
fix: resolve fresh deploy broken chat — missing flows and UnboundLocalError (#1229)#1241NPuhlmann wants to merge 2 commits intolangflow-ai:mainfrom
NPuhlmann wants to merge 2 commits intolangflow-ai:mainfrom
Conversation
…lError (langflow-ai#1229) On a fresh Docker deployment, Langflow flows were never imported into Langflow's database, causing all chat and ingestion to fail with 404s and an UnboundLocalError crash in the streaming chat path. Two fixes: 1. Call ensure_flows_exist() in the onboarding endpoint before configuring model values. On fresh deploys the background startup_tasks may not have created the flows yet (race condition). The call is idempotent so it's a no-op if startup already ran. 2. Fix indentation bugs in async_langflow_chat_stream (agent.py): - assistant_message was defined inside `if full_response:` but referenced outside it, causing UnboundLocalError when the Langflow stream returned no content. - Session claiming try/except was outside `if response_id:`, running unconditionally instead of only when a response existed.
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.
On a fresh Docker deployment, Langflow flows were never imported into Langflow's database, causing all chat and ingestion to fail with 404s and an UnboundLocalError crash in the streaming chat path.
Two fixes:
Call ensure_flows_exist() in the onboarding endpoint before configuring model values. On fresh deploys the background startup_tasks may not have created the flows yet (race condition). The call is idempotent so it's a no-op if startup already ran.
Fix indentation bugs in async_langflow_chat_stream (agent.py):
if full_response:but referenced outside it, causing UnboundLocalError when the Langflow stream returned no content.if response_id:, running unconditionally instead of only when a response existed.