{"record":{"id":"baed3d53831af07d","repo":"langflow-ai/langflow","slug":"an-internal-error-occurred-while-executing-the-flo","errorCode":null,"errorMessage":"An internal error occurred while executing the flow.","messagePattern":"An internal error occurred while executing the flow\\.","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"src/backend/base/langflow/agentic/services/flow_executor.py","lineNumber":151,"sourceCode":"        if flow_id:\n            graph.flow_id = flow_id\n        graph.flow_name = graph.flow_name or flow_filename\n\n        graph.prepare()\n        inputs = InputValueRequest(input_value=input_value) if input_value else None\n\n        results = [payload async for payload in get_default_coordinator().stream(graph, initial_inputs=inputs)]\n        flow_result = extract_structured_result(results)\n    except HTTPException:\n        raise\n    except CustomComponentValidationError as e:\n        raise HTTPException(status_code=400, detail=str(e)) from e\n    except ValueError as e:\n        logger.error(f\"Flow execution error: {e}\")\n        raise HTTPException(status_code=500, detail=\"An error occurred while executing the flow.\") from e\n    except Exception as e:\n        logger.error(f\"Flow execution error: {e}\")\n        raise HTTPException(status_code=500, detail=\"An internal error occurred while executing the flow.\") from e\n    else:\n        if isinstance(flow_result, dict):\n            flow_result[\"_metrics\"] = extract_graph_token_usage(graph)\n        return flow_result\n\n\nasync def execute_flow_file_streaming(\n    flow_filename: str,\n    input_value: str | None = None,\n    global_variables: dict[str, str] | None = None,\n    *,\n    user_id: str | None = None,\n    session_id: str | None = None,\n    provider: str | None = None,\n    model_name: str | None = None,\n    api_key_var: str | None = None,\n    is_disconnected: Callable[[], Coroutine[Any, Any, bool]] | None = None,\n    cancel_event: asyncio.Event | None = None,","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/agentic/services/flow_executor.py#L133-L169","documentation":"The non-streaming flow executor's catch-all: any exception during execution that is not HTTPException, CustomComponentValidationError, or ValueError becomes HTTP 500 with a generic detail. The real traceback is logged server-side only ('Flow execution error: {e}') so stack traces never leak to HTTP clients. It signals an unexpected internal failure — dependency errors, provider runtime failures, bugs in flow code.","triggerScenarios":"Any unclassified exception during load_graph_for_execution, graph.prepare(), or get_default_coordinator().stream() for POST /api/v1/agentic/execute/{flow_name} or /assist — e.g. a provider SDK raising RuntimeError, KeyError inside a component, network failure to the model API.","commonSituations":"Model provider API returning an unexpected error/shape; a component raising an arbitrary exception type at runtime; missing optional dependency for a component used in the flow; transient network issues to external APIs.","solutions":["Inspect backend logs for the matching 'Flow execution error:' entry to identify the true exception and fix it at the source.","Test the flow standalone in the Langflow canvas/run endpoint to isolate whether it is flow-specific.","Add/verify error handling inside the flow's components so expected external failures raise handled errors instead of bare exceptions.","Retry once — transient provider/network failures can surface here — but fix the root cause if it repeats deterministically."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt in range(2):\n    try:\n        return await execute_flow(name)\n    except HTTPException as e:\n        if e.status_code == 500 and attempt == 0 and is_possibly_transient(e):\n            await asyncio.sleep(1); continue\n        raise","preventionTips":["Retry once with backoff for 500s — transient provider/network failures land here — but escalate if deterministic.","Wrap external calls inside flow components with their own error handling so they don't bubble as bare exceptions.","Monitor server logs for 'Flow execution error:' to catch root causes early."],"tags":["agentic","flow-execution","http-500","internal-error"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}