Skip to content

fix: resolve fresh deploy broken chat — missing flows and UnboundLocalError (#1229)#1241

Open
NPuhlmann wants to merge 2 commits intolangflow-ai:mainfrom
NPuhlmann:fix/fresh-deploy-missing-flows
Open

fix: resolve fresh deploy broken chat — missing flows and UnboundLocalError (#1229)#1241
NPuhlmann wants to merge 2 commits intolangflow-ai:mainfrom
NPuhlmann:fix/fresh-deploy-missing-flows

Conversation

@NPuhlmann
Copy link
Copy Markdown

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.

…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.
@github-actions github-actions bot added community backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) bug 🔴 Something isn't working. and removed community labels Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) bug 🔴 Something isn't working.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant