{"record":{"id":"0dea4e91b2ba905c","repo":"Significant-Gravitas/AutoGPT","slug":"agent-graph-graph-id-not-found","errorCode":null,"errorMessage":"Agent graph #{graph_id} not found","messagePattern":"Agent graph #(.+?) not found","errorType":"exception","errorClass":"NotFoundError","httpStatus":404,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/store/routes.py","lineNumber":540,"sourceCode":"    \"/submissions/generate_image\",\n    summary=\"Generate submission image\",\n    tags=[\"store\", \"private\"],\n    dependencies=[Security(autogpt_libs.auth.requires_user)],\n)\nasync def generate_image(\n    graph_id: str,\n    user_id: str = Security(autogpt_libs.auth.get_user_id),\n) -> ImageURLResponse:\n    \"\"\"\n    Generate an image for a marketplace listing submission based on the properties\n    of a given graph.\n    \"\"\"\n    graph = await backend.data.graph.get_graph(\n        graph_id=graph_id, version=None, user_id=user_id\n    )\n\n    if not graph:\n        raise NotFoundError(f\"Agent graph #{graph_id} not found\")\n    # Use .jpeg here since we are generating JPEG images\n    filename = f\"agent_{graph_id}.jpeg\"\n\n    existing_url = await store_media.check_media_exists(user_id, filename)\n    if existing_url:\n        logger.info(f\"Using existing image for agent graph {graph_id}\")\n        return ImageURLResponse(image_url=existing_url)\n    # Generate agent image as JPEG\n    image = await store_image_gen.generate_agent_image(agent=graph)\n\n    # Create UploadFile with the correct filename and content_type\n    image_file = fastapi.UploadFile(\n        file=image,\n        filename=filename,\n    )\n    image_url = await store_media.upload_media(\n        user_id=user_id, file=image_file, use_file_name=True\n    )","sourceCodeStart":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/store/routes.py#L522-L558","documentation":"NotFoundError (HTTP 404) from the agent-image generation route when backend.data.graph.get_graph(graph_id, version=None, user_id=user_id) returns None. Because user_id is the authenticated caller, this fires both when the graph ID does not exist AND when the graph exists but belongs to a different user (ownership scoping).","triggerScenarios":"POST image-generation with a graph_id the caller never owned, a deleted graph, a typo'd UUID, or a graph from another user's template that was never copied into the caller's account.","commonSituations":"Stale graph ID cached in the frontend after the user deleted the agent; attempting to generate an image for another user's agent; multi-tab flows where the agent was removed.","solutions":["Confirm the graph exists for this user: GET the graph endpoint with the same authenticated user and ID.","If the graph was deleted, re-create or re-fork it before requesting image generation.","Ensure the frontend passes the graph_id from the user's own library, not a store listing's source graph."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"graph = await backend.data.graph.get_graph(\n    graph_id=graph_id, version=None, user_id=user_id\n)\nif graph is None:\n    raise HTTPException(404, f\"Graph {graph_id} not available for this user\")","typeGuard":null,"tryCatchPattern":"try:\n    image = await generate_listing_image(graph_id, user_id)\nexcept NotFoundError:\n    refresh_agent_library()  # drop stale graph reference\n    raise","preventionTips":["Clear cached graph IDs from the UI when the agent is deleted.","Only request images for graphs owned by the authenticated user."],"tags":["store","graph","not-found","ownership","image-generation"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}