{"record":{"id":"67fa5e518549616b","repo":"langflow-ai/langflow","slug":"invalid-flow-id-not-a-valid-uuid","errorCode":null,"errorMessage":"Invalid flow_id: not a valid UUID.","messagePattern":"Invalid flow_id: not a valid UUID\\.","errorType":"http","errorClass":"HTTPException","httpStatus":422,"severity":"warning","filePath":"src/backend/base/langflow/agentic/api/router.py","lineNumber":156,"sourceCode":"\n\nasync def _validate_flow_access(flow_id: str | None, user_id: UUID, session: AsyncSession) -> None:\n    \"\"\"Reject an unknown or not-owned flow_id before the model is invoked.\n\n    A missing flow_id is allowed (the assistant runs with no canvas context).\n    A supplied id must reference a flow the caller can access, mirroring the\n    per-user 404 of the /run and webhook endpoints; not-found and cross-user\n    both surface 404 so a flow's existence is not leaked by id.\n    \"\"\"\n    if not flow_id:\n        return\n\n    from langflow.services.database.models.flow import Flow\n\n    try:\n        flow_uuid = UUID(flow_id)\n    except ValueError as exc:\n        raise HTTPException(status_code=422, detail=\"Invalid flow_id: not a valid UUID.\") from exc\n\n    flow = await session.get(Flow, flow_uuid)\n    if flow is None or (flow.user_id is not None and str(flow.user_id) != str(user_id)):\n        raise HTTPException(status_code=404, detail=\"Flow not found.\")\n\n\n@router.post(\"/execute/{flow_name}\", dependencies=[Depends(require_agentic_experience)])\nasync def execute_named_flow(\n    flow_name: str,\n    request: AssistantRequest,\n    current_user: CurrentActiveUser,\n    session: DbSession,\n) -> dict:\n    \"\"\"Execute a named flow from the flows directory.\n\n    Named assistant flows embed an Agent that needs provider/model/api-key\n    context. Resolving it here (instead of running the raw file) turns a\n    silent 500 into a successful run, or a clear 4xx when no provider is set.","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/agentic/api/router.py#L138-L174","documentation":"Raised by _validate_flow_access when AssistantRequest.flow_id is supplied but cannot be parsed as a UUID by Python's UUID constructor. The flow_id is used to seed the FLOW_ID global variable for flow execution, so it must be a canonical UUID string. HTTP 422.","triggerScenarios":"POST /api/v1/agentic/assist* with flow_id set to a non-UUID string, e.g. a flow name (\"my-flow\"), an integer id, a UUID missing dashes, or a value with surrounding whitespace/typo.","commonSituations":"Client sends the flow's display name or slug instead of its id; copying an id with a truncated character; passing a null-ish placeholder like \"undefined\" or \"null\" from JavaScript when the flow was never selected.","solutions":["Send the flow's actual UUID (from the flow's URL or GET /api/v1/flows) in flow_id.","Omit flow_id entirely when no canvas flow context is needed — the validator returns early for empty values.","In JS clients, guard against 'undefined'/'null' stringification before building the payload."],"exampleFix":"// before\nbody: JSON.stringify({input_value: q, flow_id: flowName}) // 'my assistant flow'\n// after\nbody: JSON.stringify({input_value: q, flow_id: flowId}) // '3fa85f64-5717-4562-b3fc-2c963f66afa6'","handlingStrategy":"validation","validationCode":"const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nconst safeFlowId = (id) => (id && UUID_RE.test(id) ? id : undefined); // omit invalid instead of sending","typeGuard":"function isUuidString(s: string): boolean {\n  return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s);\n}","tryCatchPattern":"On 422 'Invalid flow_id', strip flow_id from the payload and retry once without canvas context.","preventionTips":["Always source flow_id from API responses (GET /api/v1/flows), never from user input or names.","Guard JS against 'undefined'/'null' stringification of unselected flows.","Remember flow_id is optional — omit it when no flow context is needed."],"tags":["agentic","flow-id","uuid","http-422","validation"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}