{"record":{"id":"4f5685d103386adc","repo":"Significant-Gravitas/AutoGPT","slug":"failed-to-create-store-submission-review","errorCode":null,"errorMessage":"Failed to create store submission review","messagePattern":"Failed to create store submission review","errorType":"exception","errorClass":"DatabaseError","httpStatus":500,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/store/db.py","lineNumber":1588,"sourceCode":"            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\n    except NotFoundError:\n        raise\n    except Exception as e:\n        logger.error(f\"Could not create store submission review: {e}\")\n        raise DatabaseError(\"Failed to create store submission review\") from e\n\n\nasync def _approve_sub_agent(\n    tx,\n    sub_graph: prisma.models.AgentGraph,\n    main_agent_name: str,\n    main_agent_graph_version: int,\n    main_agent_user_id: str,\n) -> None:\n    \"\"\"Approve a single sub-agent by creating/updating store listings as needed\"\"\"\n    heading = f\"Sub-agent of {main_agent_name} v{main_agent_graph_version}\"\n\n    # Find existing listing for this sub-agent\n    listing = await prisma.models.StoreListing.prisma(tx).find_first(\n        where={\"agentGraphId\": sub_graph.id, \"isDeleted\": False},\n        include={\"Versions\": True},\n    )\n","sourceCodeStart":1570,"sourceCodeEnd":1606,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/store/db.py#L1570-L1606","documentation":"Catch-all DatabaseError at the bottom of review_store_submission(). Any exception other than the re-raised NotFoundError — the update transaction, sub-agent approval (_approve_sub_agent), notification model construction, or serialization into StoreSubmissionAdminView — is logged as 'Could not create store submission review' and re-wrapped here.","triggerScenarios":"Admin approve/reject where approving triggers sub-agent store-listing creation, listing updates, or StoreSubmissionAdminView.from_listing_version() and any of those steps throws (missing relation in the include, constraint violation, Prisma error).","commonSituations":"Approving an agent whose sub-agents reference deleted graphs, schema drift where included relations changed shape, or partial update data violating a NOT NULL/unique constraint.","solutions":["Check the server log for 'Could not create store submission review: {e}' — the chained cause names the failing step.","If the cause is in _approve_sub_agent, inspect the sub-agent AgentGraph records for the reviewed submission.","Re-run `poetry run prisma generate` if the cause is a missing/relation field after schema changes.","Verify the DB state was not half-updated (the update and sub-agent steps are not one transaction) and reconcile if needed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    view = await store_db.review_store_submission(...)\nexcept DatabaseError as e:\n    logger.exception(\"Review failed\")\n    raise HTTPException(503, \"Review could not be recorded; state may be partial\") from e","preventionTips":["Never assume the review is atomic — the update and sub-agent approval steps are separate; verify final submission state after errors.","Keep integration tests covering approve-with-sub-agents to catch _approve_sub_agent regressions early."],"tags":["store","admin","database","prisma"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}