{"record":{"id":"9db33c809213c3ec","repo":"Significant-Gravitas/AutoGPT","slug":"graph-graph-id-not-found-in-user-s-library","errorCode":null,"errorMessage":"Graph #{graph_id} not found in user's library","messagePattern":"Graph #(.+?) not found in user's library","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"warning","filePath":"autogpt_platform/backend/backend/api/features/v1.py","lineNumber":1939,"sourceCode":"\n@v1_router.patch(\n    path=\"/graphs/{graph_id}/settings\",\n    summary=\"Update graph settings\",\n    tags=[\"graphs\"],\n    dependencies=[Security(requires_user)],\n)\nasync def update_graph_settings(\n    graph_id: str,\n    settings: GraphSettings,\n    user_id: Annotated[str, Security(get_user_id)],\n    ctx: Annotated[RequestContext, Security(get_request_context)],\n) -> GraphSettings:\n    \"\"\"Update graph settings for the user's library agent.\"\"\"\n    library_agent = await library_db.get_library_agent_by_graph_id(\n        graph_id=graph_id, user_id=user_id\n    )\n    if not library_agent:\n        raise HTTPException(404, f\"Graph #{graph_id} not found in user's library\")\n\n    updated_agent = await library_db.update_library_agent(\n        library_agent_id=library_agent.id,\n        user_id=user_id,\n        settings=settings,\n    )\n\n    return GraphSettings.model_validate(updated_agent.settings)\n\n\n@v1_router.post(\n    path=\"/graphs/{graph_id}/execute/{graph_version}\",\n    summary=\"Execute graph agent\",\n    tags=[\"graphs\"],\n    dependencies=[Security(requires_user), Depends(enforce_payment_paywall)],\n    # The route dep enforces fail-closed (503-on-blip) so a transient\n    # Supabase outage surfaces as a retryable error, not a free run\n    # for a paywalled user. The deep gate inside ``add_graph_execution``","sourceCodeStart":1921,"sourceCodeEnd":1957,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/v1.py#L1921-L1957","documentation":"Raised (404) by PUT /graphs/{graph_id}/settings when library_db.get_library_agent_by_graph_id finds no library agent for that graph_id and user. Graph settings (like the library agent's display settings) live on the user's library-agent record, so this fails when the graph exists but was never added to the user's library, or was removed from it.","triggerScenarios":"Updating settings for a graph the user can reference (e.g. marketplace agent) but has not cloned/added to their library; after removing the agent from the library while a settings panel stayed open.","commonSituations":"Marketplace flows where the graph is visible but not yet in 'My Library'; library sync lag right after graph creation; settings pages left open across a library reset.","solutions":["Add/clone the agent into the user's library first (library add endpoint), then retry the settings update.","If it was removed, re-add it and reapply settings.","Verify with the library listing endpoint that a library agent exists for this graph_id before showing an editable settings UI."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const library = await api.listLibraryAgents();\nconst inLibrary = library.some(a => a.graph_id === graphId);\nif (!inLibrary) { await api.addGraphToLibrary(graphId); }\nawait api.updateGraphSettings(graphId, settings);","typeGuard":"const isGraphInLibrary = (id: string, agents: LibraryAgent[]) => agents.some(a => a.graphId === id);","tryCatchPattern":"catch (e) { if (e.response?.status === 404 && /library/.test(e.response.data.detail)) { promptAddToLibrary(); } else throw e; }","preventionTips":["Only render the settings panel for agents present in the user's library.","In marketplace flows, make 'add to library' a prerequisite step before settings edits.","Handle library-removal events by closing open settings panels."],"tags":["api","graphs","library","settings","http-404"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}