{"record":{"id":"c10374431366a0b8","repo":"Significant-Gravitas/AutoGPT","slug":"user-does-not-have-a-profile-yet","errorCode":null,"errorMessage":"User does not have a profile yet","messagePattern":"User does not have a profile yet","errorType":"exception","errorClass":"NotFoundError","httpStatus":404,"severity":"warning","filePath":"autogpt_platform/backend/backend/api/features/store/routes.py","lineNumber":49,"sourceCode":"\n##############################################\n############### Profile Endpoints ############\n##############################################\n\n\n@router.get(\n    \"/profile\",\n    summary=\"Get user profile\",\n    tags=[\"store\", \"private\"],\n    dependencies=[Security(autogpt_libs.auth.requires_user)],\n)\nasync def get_profile(\n    user_id: str = Security(autogpt_libs.auth.get_user_id),\n) -> store_model.ProfileDetails:\n    \"\"\"Get the profile details for the authenticated user.\"\"\"\n    profile = await store_db.get_user_profile(user_id)\n    if profile is None:\n        raise NotFoundError(\"User does not have a profile yet\")\n    return profile\n\n\n@router.post(\n    \"/profile\",\n    summary=\"Update user profile\",\n    tags=[\"store\", \"private\"],\n    dependencies=[Security(autogpt_libs.auth.requires_user)],\n)\nasync def update_or_create_profile(\n    profile: store_model.Profile,\n    user_id: str = Security(autogpt_libs.auth.get_user_id),\n) -> store_model.ProfileDetails:\n    \"\"\"Update the store profile for the authenticated user.\"\"\"\n    updated_profile = await store_db.update_profile(user_id=user_id, profile=profile)\n    return updated_profile\n\n","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/store/routes.py#L31-L67","documentation":"NotFoundError (HTTP 404) from GET /store/profile when store_db.get_user_profile(user_id) returns None: the authenticated user exists in auth (Supabase JWT valid) but has no row in the store Profile table yet. It is an expected 'empty state', not a malfunction.","triggerScenarios":"First authenticated call to /store/profile by a brand-new user before any profile-creating action; a user whose profile row was deleted; or an environment where profile creation is lazy and the UI visits the profile page first.","commonSituations":"Fresh signup landing on the store/profile page; API consumers probing profile before the user completed onboarding.","solutions":["Treat 404 as 'no profile yet': create one via POST /store/profile with a Profile payload.","In the UI, render an empty-profile state instead of an error on 404.","If the user should have a profile, verify the correct user_id is being sent (wrong Supabase user / spoofed ID mismatch)."],"exampleFix":"// before\nconst profile = await api.getStoreProfile(); // 404 crashes flow\n\n// after\nlet profile: ProfileDetails | null = null;\ntry {\n  profile = await api.getStoreProfile();\n} catch (e) {\n  if (e.status !== 404) throw e;\n  profile = null; // empty state -> offer POST /store/profile\n}","handlingStrategy":"fallback","validationCode":"profile = await store_db.get_user_profile(user_id)\nhas_profile = profile is not None","typeGuard":null,"tryCatchPattern":"try:\n    profile = await store_db.get_user_profile(user_id)\nexcept NotFoundError:\n    profile = None  # empty state\nif profile is None:\n    profile = await create_default_profile(user_id)  # POST /store/profile","preventionTips":["Create the profile eagerly on first authenticated session if the UX expects one.","Treat 404 on GET /store/profile as a normal empty state in clients."],"tags":["store","profile","not-found","empty-state"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}