mirror of
https://github.com/reconurge/flowsint.git
synced 2026-11-10 01:45:55 -06:00
[GH-ISSUE #166] AI Assistant shows 'Failed to fetch' when no LLM API key is configured in Vault #3142
Reference in New Issue
Block a user
Originally created by @adityaa206 on GitHub (Jun 3, 2026).
Original GitHub issue: https://github.com/reconurge/flowsint/issues/166
Originally assigned to: @Lakshya77089 on GitHub.
Description
When a user opens the New Template → AI Assistant panel and sends a prompt, the response is always:
This happens because no LLM API key (e.g.
MISTRAL_API_KEY) has been stored in the user's Vault. The error is silent and gives the user no actionable guidance.Root Cause
Bug 1 — Unhandled
ValueErrorin the/generaterouteIn
flowsint-api/app/api/routes/enricher_templates.py(lines 113–123), thegeneratecall is wrapped inexcept ValidationError, but the LLM factory raises aValueError(not aValidationError) when the API key is missing:Because
ValueErroris not caught, FastAPI returns an unhandled 500 Internal Server Error. In some cases this 500 response is missing CORS headers, so the browser throwsTypeError: Failed to fetchwith no useful detail — matching the symptom exactly.Confirmed in API container logs:
Bug 2 — No pre-flight key check in the AI Assistant UI
flowsint-app/src/components/templates/ai-chat-panel.tsxsends the prompt directly without first checking whether an LLM API key exists in the Vault. A/keys/exists/{key_name}endpoint already exists in the backend and could be used to show actionable guidance instead of the generic error.Steps to Reproduce
I encountered an error: Failed to fetch. Please try again.Expected Behavior
ValueErrorand return a 422 with a clear message:"LLM API key not configured. Please add MISTRAL_API_KEY to your Vault."Suggested Fix
Backend (
flowsint-api/app/api/routes/enricher_templates.py) — also catchValueError:Frontend (
flowsint-app/src/components/templates/ai-chat-panel.tsx) — check key existence on mount and show a warning banner:Environment
mistral(env default, no override set)Related Files
flowsint-api/app/api/routes/enricher_templates.py— missingValueErrorcatchflowsint-core/src/flowsint_core/core/llm/factory.py— raisesValueErroron missing keyflowsint-core/src/flowsint_core/core/services/template_generator_service.py— calls_get_llm_providerwithout catchingflowsint-app/src/components/templates/ai-chat-panel.tsx— no pre-flight key checkflowsint-app/src/api/key-service.ts— existingexists()helper available for the pre-check@Lakshya77089 commented on GitHub (Jun 3, 2026):
Hi @adityaa206,
I'd like to work on this issue.
From the description, it looks like there are two parts to address:
ValueErrorand returning a proper422response.I'll investigate the existing implementation and submit a PR if the issue is still available. Could you please assign it to me?
Thanks!
@dextmorgn commented on GitHub (Jun 3, 2026):
@adityaa206 thanks for creating this issue !
@Lakshya77089 kudos on taking the lead !
For the frontend, you can use already existing hook
flowsint-app/src/hooks/use-is-chat-active.tsthat does exactly this.Example in
flowsint-app/src/components/chat/floating-chat.tsx