{"record":{"id":"5142f1c738f4d992","repo":"Significant-Gravitas/AutoGPT","slug":"failed-to-get-user-profile","errorCode":null,"errorMessage":"Failed to get user profile","messagePattern":"Failed to get user profile","errorType":"exception","errorClass":"DatabaseError","httpStatus":500,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/store/db.py","lineNumber":1203,"sourceCode":"        raise DatabaseError(\"Failed to create store review\") from e\n\n\nasync def get_user_profile(\n    user_id: str,\n) -> store_model.ProfileDetails | None:\n    logger.debug(f\"Getting user profile for {user_id}\")\n\n    try:\n        profile = await prisma.models.Profile.prisma().find_first(\n            where={\"userId\": user_id}\n        )\n\n        if not profile:\n            return None\n        return store_model.ProfileDetails.from_db(profile)\n    except Exception as e:\n        logger.error(f\"Error getting user profile: {e}\")\n        raise DatabaseError(\"Failed to get user profile\") from e\n\n\nasync def update_profile(\n    user_id: str, profile: store_model.Profile\n) -> store_model.ProfileDetails:\n    \"\"\"\n    Update the store profile for a user or create a new one if it doesn't exist.\n    Args:\n        user_id: ID of the authenticated user\n        profile: Updated profile details\n    Returns:\n        ProfileDetails: The updated or created profile details\n    Raises:\n        DatabaseError: If there's an issue updating or creating the profile\n    \"\"\"\n    logger.info(f\"Updating profile for user {user_id} with data: {profile}\")\n    try:\n        # Sanitize username to allow only letters, numbers, and hyphens","sourceCodeStart":1185,"sourceCodeEnd":1221,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/store/db.py#L1185-L1221","documentation":"Catch-all DatabaseError from get_user_profile: any exception while running the Profile find_first or converting via ProfileDetails.from_db. Note that 'profile not found' is NOT an error here — the function returns None in that case — so this message always indicates an infrastructure or mapping failure.","triggerScenarios":"DB unreachable when loading the profile page; ProfileDetails.from_db encountering an unexpected column type after a schema migration; Prisma client not regenerated after new Profile fields were added.","commonSituations":"Deploying schema changes without 'poetry run prisma generate'; regional DB failover; stale build artifacts in a container.","solutions":["Check the chained exception in the 'Error getting user profile' log line.","Regenerate the Prisma client and restart the backend if the schema changed.","Verify DB connectivity if the error is intermittent."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from backend.util.exceptions import DatabaseError\n\ntry:\n    profile = await store_db.get_user_profile(user_id)\nexcept DatabaseError:\n    profile = None  # profile is optional; degrade gracefully on infra failure\nif profile is None:\n    render_anonymous_profile_defaults()","preventionTips":["Remember None means 'no profile yet' (valid state); only DatabaseError means failure.","Regenerate the Prisma client whenever Profile columns change.","Keep profile fetch off the critical path where possible; cache per request."],"tags":["database","prisma","profile","store"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}