{"record":{"id":"adaf389680df8357","repo":"langflow-ai/langflow","slug":"str-e-adaf38","errorCode":null,"errorMessage":"str(e)","messagePattern":"str\\(e\\)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"src/backend/base/langflow/api/v1/flows_helpers.py","lineNumber":350,"sourceCode":"\n        # Apply the stable ID: explicit flow_id param (PUT upsert) takes precedence,\n        # then flow.id (stable import from FlowCreate), then the uuid4 default.\n        effective_id = flow_id if flow_id is not None else flow.id\n        if effective_id is not None:\n            db_flow.id = effective_id\n\n        db_flow.updated_at = datetime.now(timezone.utc)\n        await _validate_and_assign_folder(session, db_flow, user_id)\n\n        session.add(db_flow)\n        await session.flush()\n        await session.refresh(db_flow)\n        await _save_flow_to_fs(db_flow, user_id, storage_service)\n\n        return FlowRead.model_validate(db_flow, from_attributes=True)\n    except Exception as e:\n        if hasattr(e, \"errors\"):\n            raise HTTPException(status_code=400, detail=str(e)) from e\n        if isinstance(e, HTTPException):\n            raise\n        logger.exception(\"Error creating flow\")\n        raise HTTPException(status_code=500, detail=\"An internal error occurred while creating the flow.\") from e\n\n\nasync def _read_flow(\n    session: AsyncSession,\n    flow_id: UUID,\n    user_id: UUID,\n):\n    \"\"\"Read a flow.\n\n    When the registered authorization service supports cross-user fetch\n    (authorization plugin), the row is loaded by id alone and the caller's\n    ``ensure_flow_permission`` decides access. Otherwise the query stays\n    owner-scoped so the OSS pass-through default cannot widen visibility.\n    \"\"\"","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/api/v1/flows_helpers.py#L332-L368","documentation":"HTTP 400 from _create_flow's catch-all: the raised exception has an `errors` attribute — the signature of a Pydantic ValidationError (raised by Flow.model_validate / FlowRead.model_validate / field coercion inside creation). The exception's str() (which includes per-field error details) becomes the response detail, and genuine HTTPExceptions are re-raised before this branch.","triggerScenarios":"POST /api/v1/flows (or import/upsert paths calling _create_flow) with a payload that fails Pydantic validation during ORM->model conversion or field assignment — wrong types for flow.data, invalid datetime on updated_at handling, or a field constraint violated that request schema validation did not catch.","commonSituations":"data is a list or string instead of a dict; timestamps serialized in a non-ISO format; enum fields (e.g. flow style/visibility) given unknown values; sending null for a required field that the request model marks optional but the ORM model does not.","solutions":["Read the response detail: str(ValidationError) lists each failing field and reason — fix those fields.","Validate the payload client-side against the FlowCreate schema before posting.","If the error names a field you never sent, suspect server-side model coercion and check version mismatch between client schema and server."],"exampleFix":"# before\n{\"name\": \"f\", \"data\": [1, 2]}          # data must be a dict\n# after\n{\"name\": \"f\", \"data\": {\"nodes\": [], \"edges\": []}}","handlingStrategy":"validation","validationCode":"if (typeof body.data !== 'object' || body.data === null || Array.isArray(body.data)) throw new Error('flow.data must be a dict');","typeGuard":"const isFlowData = (d: unknown): d is {nodes: unknown[]; edges: unknown[]} => typeof d === 'object' && d !== null && !Array.isArray(d) && 'nodes' in d && 'edges' in d;","tryCatchPattern":"try { await createFlow(body) } catch (e) { if (e.status === 400 && e.detail.includes('validation')) showFieldErrors(e.detail); throw e; }","preventionTips":["Validate against the FlowCreate schema client-side","Send data as a dict with nodes/edges arrays","Parse the Pydantic error list in detail to fix exact fields"],"tags":["validation","pydantic","http-400","flows"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}