{"record":{"id":"e19c9e3f8944d1b0","repo":"langflow-ai/langflow","slug":"an-error-occurred-while-executing-the-flow","errorCode":null,"errorMessage":"An error occurred while executing the flow.","messagePattern":"An 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":148,"sourceCode":"            graph.context[\"request_variables\"].update(global_variables)\n\n        flow_id = (global_variables or {}).get(\"FLOW_ID\")\n        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,","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/agentic/services/flow_executor.py#L130-L166","documentation":"The non-streaming flow executor maps any ValueError raised during graph load/prepare/run (that is not a CustomComponentValidationError) to a generic HTTP 500. The real exception text is logged server-side ('Flow execution error: {e}') but deliberately withheld from the client. ValueErrors here typically come from graph construction, missing components, or invalid flow definitions.","triggerScenarios":"POST /api/v1/agentic/execute/{flow_name} where loading the flow file raises ValueError — e.g. flow JSON/Python references an unknown component type, a malformed graph, get_graph() returning something invalid — during load_graph_for_execution, graph.prepare(), or coordinator stream.","commonSituations":"Flow file references a component removed/renamed in an upgrade; flow built on a newer Langflow version than the server; malformed hand-edited flow JSON producing invalid vertex/edge data.","solutions":["Check the backend logs for the 'Flow execution error:' line — it contains the actual ValueError message; fix that root cause.","Open the flow in the Langflow editor and re-save to revalidate components; replace components flagged as missing.","Regenerate the .py/.json flow file from a working canvas export rather than hand-editing.","Ensure server and flow authoring environment run the same Langflow version."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"except HTTPException as e:\n    if e.status_code == 500 and 'executing the flow' in e.detail:\n        log_correlation_id(); alert_operator('check server logs: Flow execution error')\n        return friendly_error_page()","preventionTips":["Correlate client errors with server logs via request id/timestamp — the real ValueError is only server-side.","Open flows in the canvas after upgrading Langflow to flush stale component references.","Version-pin flow files together with the Langflow release they were built for."],"tags":["agentic","flow-execution","http-500","valueerror","logging"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}