{"record":{"id":"f328670c704308a5","repo":"Significant-Gravitas/AutoGPT","slug":"failed-to-update-store-listing-version-store-list","errorCode":null,"errorMessage":"Failed to update store listing version {store_listing_version_id}","messagePattern":"Failed to update store listing version (.+?)","errorType":"exception","errorClass":"DatabaseError","httpStatus":500,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/store/db.py","lineNumber":1565,"sourceCode":"            \"submissionStatus\": submission_status,\n            \"reviewedAt\": datetime.now(tz=timezone.utc),\n            \"Reviewer\": {\"connect\": {\"id\": reviewer_id}},\n            \"reviewComments\": external_comments,\n            \"internalComments\": internal_comments,\n        }\n\n        # Update the version\n        reviewed_submission = await prisma.models.StoreListingVersion.prisma().update(\n            where={\"id\": store_listing_version_id},\n            data=update_data,\n            include={\n                \"StoreListing\": True,  # required for StoreSubmissionAdminView\n                \"Reviewer\": True,  # used in _send_submission_review_notification\n            },\n        )\n\n        if not reviewed_submission:\n            raise DatabaseError(\n                f\"Failed to update store listing version {store_listing_version_id}\"\n            )\n\n        try:\n            await _send_submission_review_notification(\n                creator_user_id,\n                is_approved,\n                external_comments,\n                reviewed_submission,\n            )\n        except Exception as e:\n            logger.error(f\"Failed to send email notification for agent review: {e}\")\n            # Don't fail the review process if email sending fails\n\n        return store_model.StoreSubmissionAdminView.from_listing_version(\n            reviewed_submission\n        )\n","sourceCodeStart":1547,"sourceCodeEnd":1583,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/store/db.py#L1547-L1583","documentation":"DatabaseError raised inside review_store_submission() when prisma StoreListingVersion.update(...) returns None after the review decision. Prisma update returns None only when the where-unique record vanished between the initial fetch and the update (or the write failed to match), i.e. a lost-update race during admin review.","triggerScenarios":"Admin A and admin B open the same submission; B approves (or the creator deletes the submission) before A's update commits, so A's update matches zero rows and returns None.","commonSituations":"Double-clicking the approve/reject button, multiple admin tabs, long review sessions where the submission is removed, or retry logic re-running after the record was deleted.","solutions":["Refresh the submission queue and re-check status before retrying the review — the record was likely already reviewed or deleted.","Guard against duplicate submissions in the admin UI (disable the button while the request is in flight).","If it persists for a known-live record, verify the ID format and that no cascade delete removed StoreListingVersion rows."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"tr = await prisma.models.StoreListingVersion.prisma().find_unique(\n    where={\"id\": store_listing_version_id}\n)\nstill_reviewable = tr is not None and tr.submissionStatus == \"PENDING\"","typeGuard":null,"tryCatchPattern":"try:\n    view = await store_db.review_store_submission(...)\nexcept DatabaseError as e:\n    if \"Failed to update store listing version\" in str(e):\n        recheck = await fetch_submission(store_listing_version_id)\n        if recheck is None or recheck.status != \"PENDING\":\n            return already_handled_response()  # lost race, not a fault\n        raise","preventionTips":["Disable the approve/reject button while a review request is in flight.","Re-check submission status immediately before submitting a review.","Design the admin queue to tolerate 409/lost-update outcomes."],"tags":["store","admin","race-condition","prisma"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}