{"record":{"id":"f42f5bce9dc54bda","repo":"Significant-Gravitas/AutoGPT","slug":"expert-not-found","errorCode":null,"errorMessage":"Expert not found","messagePattern":"Expert not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/chat/routes.py","lineNumber":680,"sourceCode":"    Returns:\n        CreateSessionResponse: Details of the resulting session.\n    \"\"\"\n    dry_run = request.dry_run if request else False\n    builder_graph_id = request.builder_graph_id if request else None\n    expert_id = request.expert_id if request else None\n\n    # The builder branch below ignores expert_id, so accepting both would\n    # validate the expert and then silently drop the scoping. Reject upfront.\n    if builder_graph_id and expert_id:\n        raise HTTPException(\n            status_code=422,\n            detail=\"builder_graph_id and expert_id are mutually exclusive\",\n        )\n\n    if expert_id is not None:\n        expert = await experts_db.get_expert(user_id, expert_id)\n        if expert is None or expert.is_archived:\n            raise HTTPException(status_code=404, detail=\"Expert not found\")\n\n    llm_auth_provider, llm_credential_id = await _resolve_new_session_llm_route(\n        user_id, request\n    )\n\n    if llm_auth_provider == \"platform\":\n        await enforce_payment_paywall(user_id)\n\n    logger.info(\n        f\"Creating session with user_id: \"\n        f\"...{user_id[-8:] if len(user_id) > 8 else '<redacted>'}\"\n        f\"{', dry_run=True' if dry_run else ''}\"\n        f\"{f', builder_graph_id={builder_graph_id}' if builder_graph_id else ''}\"\n        f\"{f', expert_id={expert_id}' if expert_id else ''}\"\n    )\n\n    if builder_graph_id:\n        if llm_auth_provider == \"codex\":","sourceCodeStart":662,"sourceCodeEnd":698,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/chat/routes.py#L662-L698","documentation":"A 404 from create_session's expert branch: expert_id was supplied, but experts_db.get_expert(user_id, expert_id) returned None or an expert with is_archived=true. The lookup is scoped to the requesting user, so a valid expert owned by someone else is indistinguishable from a nonexistent one.","triggerScenarios":"POST /chat/sessions with expert_id that was deleted, archived (is_archived=true), belongs to another user, or came from a different environment.","commonSituations":"Expert archived in the marketplace/experts UI while the client still shows its card; stale expert id cached from a previous session or another workspace; environment mismatch (dev id against prod API).","solutions":["Refresh the experts list in the client and only allow starting chats with non-archived experts owned by the current user.","If the expert should be usable, un-archive it in the experts management UI first.","Check that the authenticated user actually owns the expert — sharing another user's expert id yields this same 404."],"exampleFix":"// before\ncreateSession({expert_id: cachedExpertId})\n\n// after\nconst experts = await listExperts(userId);\nconst active = experts.find(e => e.id === expertId && !e.is_archived);\nif (active) createSession({expert_id: active.id});","handlingStrategy":"try-catch","validationCode":"const experts = await listExperts(userId);\nconst usable = experts.find(x => x.id === expertId && !x.is_archived);\nif (!usable) { refreshExpertPicker(); return; }\nawait createSession({expert_id: usable.id});","typeGuard":"function isStartableExpert(e: {id: string; is_archived: boolean} | null, id: string): boolean {\n  return e != null && e.id === id && !e.is_archived;\n}","tryCatchPattern":"try {\n  await createSession({expert_id: expertId});\n} catch (e) {\n  if (e.status === 404) { refreshExperts(); showExpertUnavailable(); return; }\n  throw e;\n}","preventionTips":["Filter archived experts out of 'start chat' entry points.","Refetch the expert before chatting if the list is older than the current view.","Remember ownership: another user's expert id 404s identically."],"tags":["backend","chat","experts","http-404"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}