{"record":{"id":"716a27110f70624e","repo":"Significant-Gravitas/AutoGPT","slug":"graph-graph-id-v-new-active-version-not-found","errorCode":null,"errorMessage":"Graph #{graph_id} v{new_active_version} not found","messagePattern":"Graph #(.+?) v(.+?) not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"warning","filePath":"autogpt_platform/backend/backend/api/features/v1.py","lineNumber":1878,"sourceCode":"\n@v1_router.put(\n    path=\"/graphs/{graph_id}/versions/active\",\n    summary=\"Set active graph version\",\n    tags=[\"graphs\"],\n    dependencies=[Security(requires_user)],\n)\nasync def set_graph_active_version(\n    graph_id: str,\n    request_body: SetGraphActiveVersion,\n    user_id: Annotated[str, Security(get_user_id)],\n    ctx: Annotated[RequestContext, Security(get_request_context)],\n) -> SetActiveGraphVersionResponse:\n    new_active_version = request_body.active_graph_version\n    new_active_graph = await graph_db.get_graph(\n        graph_id, new_active_version, user_id=user_id\n    )\n    if not new_active_graph:\n        raise HTTPException(404, f\"Graph #{graph_id} v{new_active_version} not found\")\n\n    current_active_graph = await graph_db.get_graph(\n        graph_id=graph_id,\n        version=None,\n        user_id=user_id,\n    )\n\n    # Validate the new graph's credentials before flipping the active version.\n    # Capture the returned graph: before_graph_activate may clear stale\n    # optional credential references, which we want propagated to the library\n    # agent's settings sync below.\n    new_active_graph = await before_graph_activate(new_active_graph, user_id=user_id)\n    # Ensure new version is the only active version\n    await graph_db.set_graph_active_version(\n        graph_id=graph_id,\n        version=new_active_version,\n        user_id=user_id,\n    )","sourceCodeStart":1860,"sourceCodeEnd":1896,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/v1.py#L1860-L1896","documentation":"Raised (404) by POST /graphs/{graph_id}/active_version when graph_db.get_graph(graph_id, active_graph_version, user_id) returns nothing — the specific version number in SetGraphActiveVersion does not exist for this user's graph. Version numbers are per-graph integers; activating a nonexistent one is a client error.","triggerScenarios":"Posting {\"active_graph_version\": 7} when the graph only has versions 1-3 — stale version dropdown after another client created/deleted versions, or a hard-coded version number from a different graph.","commonSituations":"Two builder sessions editing the same agent: session A publishes v3 while session B (still showing v5 from a deleted branch) tries to activate v5; API scripts re-using recorded version numbers across graph re-creations.","solutions":["Re-fetch /graphs/{graph_id}/versions and pick a version that actually exists before activating.","In the UI, refresh the version list right before the activate action to shrink the race window.","Handle 404 by prompting the user to reload rather than silently retrying the same number."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const versions = await api.getGraphVersions(graphId);\nconst exists = versions.some(v => v.version === targetVersion);\nif (!exists) { refreshVersionPicker(versions); return; }\nawait api.setActiveVersion(graphId, targetVersion);","typeGuard":"const versionExists = (n: number, versions: {version: number}[]) => versions.some(v => v.version === n);","tryCatchPattern":"catch (e) { if (e.response?.status === 404) { reloadVersionsAndNotifyUser(); } else throw e; }","preventionTips":["Fetch the version list immediately before the activate call to shrink race windows.","Never hard-code version numbers; always reference a version ID just fetched.","On 404, refresh state instead of retrying the same stale number."],"tags":["api","graphs","versions","http-404","concurrency"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}