{"record":{"id":"5a26e2f822fc40da","repo":"Significant-Gravitas/AutoGPT","slug":"validation-error","errorCode":null,"errorMessage":"validation_error","messagePattern":"validation_error","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/v1.py","lineNumber":2017,"sourceCode":"            organization_id=ctx.org_id,\n            team_id=ctx.team_id,\n        )\n        # Record successful graph execution\n        record_graph_execution(graph_id=graph_id, status=\"success\", user_id=user_id)\n        record_graph_operation(operation=\"execute\", status=\"success\")\n        if source == \"library\":\n            await complete_onboarding_step(user_id, OnboardingStep.LIBRARY_RUN_AGENT)\n        elif source == \"builder\":\n            await complete_onboarding_step(user_id, OnboardingStep.BUILDER_RUN_AGENT)\n        return result\n    except GraphValidationError as e:\n        # Record failed graph execution\n        record_graph_execution(\n            graph_id=graph_id, status=\"validation_error\", user_id=user_id\n        )\n        record_graph_operation(operation=\"execute\", status=\"validation_error\")\n        # Return structured validation errors that the frontend can parse\n        raise HTTPException(\n            status_code=400,\n            detail={\n                \"type\": \"validation_error\",\n                \"message\": e.message,\n                # TODO: only return node-specific errors if user has access to graph\n                \"node_errors\": e.node_errors,\n            },\n        )\n    except Exception:\n        # Record any other failures\n        record_graph_execution(graph_id=graph_id, status=\"error\", user_id=user_id)\n        record_graph_operation(operation=\"execute\", status=\"error\")\n        raise\n\n\n@v1_router.post(\n    path=\"/graphs/{graph_id}/executions/{graph_exec_id}/stop\",\n    summary=\"Stop graph execution\",","sourceCodeStart":1999,"sourceCodeEnd":2035,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/v1.py#L1999-L2035","documentation":"Raised (400) by the graph execute endpoint when graph validation (GraphValidationError) fails before scheduling. The detail is a structured object, not a string: {type: 'validation_error', message, node_errors} where node_errors maps node IDs to per-node problems — designed so the frontend can highlight the exact faulty nodes in the builder.","triggerScenarios":"Executing a graph with invalid structure: unconnected required input pins, nodes missing required input values or credentials, cycles or subgraph wiring errors. The graph passes deserialization but fails validate_graph/credential checks at execution time.","commonSituations":"Running a half-built agent in the builder; another client edited the graph and left it invalid; a block's schema changed across versions so previously-valid inputs now fail validation; missing API-key credentials for LLM blocks.","solutions":["Parse detail.node_errors and surface each node's message at that node in the builder UI.","Fix the flagged inputs/connections (supply required values, attach credentials) and re-run.","If schemas changed, open the graph in the builder and re-save so it migrates to the current block schema.","Use dry_run=true to validate without consuming credits while iterating."],"exampleFix":"// before\ncatch (e) { alert('Run failed'); }\n\n// after\nconst detail = e.response?.data?.detail;\nif (detail?.type === 'validation_error') {\n  for (const [nodeId, msg] of Object.entries(detail.node_errors)) {\n    highlightNode(nodeId, msg);\n  }\n} else { throw e; }","handlingStrategy":"type-guard","validationCode":"const missing = requiredInputs.filter(k => !inputs[k]);\nif (missing.length) { highlightNodes(missing); return; }\nawait api.executeGraph(graphId, { inputs });","typeGuard":"interface GraphValidationDetail {\n  type: 'validation_error';\n  message: string;\n  node_errors: Record<string, string>;\n}\nconst isGraphValidationDetail = (d: unknown): d is GraphValidationDetail =>\n  typeof d === 'object' && d !== null && (d as any).type === 'validation_error';","tryCatchPattern":"catch (e) {\n  const detail = e.response?.data?.detail;\n  if (isGraphValidationDetail(detail)) {\n    for (const [nodeId, msg] of Object.entries(detail.node_errors)) markNodeInvalid(nodeId, msg);\n  } else throw e;\n}","preventionTips":["Parse node_errors and annotate the offending nodes in the builder instead of showing a generic toast.","Run dry_run=true as a pre-flight validation before the real (paid) execution.","Re-save graphs in the builder after block schema upgrades so stale inputs surface at edit time, not run time."],"tags":["api","graphs","execution","validation","http-400"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}