{"record":{"id":"644ba6c809e04652","repo":"Significant-Gravitas/AutoGPT","slug":"failed-to-create-store-submission","errorCode":null,"errorMessage":"Failed to create store submission","messagePattern":"Failed to create store submission","errorType":"exception","errorClass":"DatabaseError","httpStatus":500,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/store/db.py","lineNumber":1026,"sourceCode":"        if \"slug\" in error_str.lower():\n            logger.debug(f\"Slug '{slug}' is already in use by graph #{graph_id}\")\n            raise store_exceptions.SlugAlreadyInUseError(\n                f\"The slug '{slug}' is already in use by another one of your agents. \"\n                \"Please choose a different slug.\"\n            ) from exc\n        else:\n            # Reraise as a generic database error for other unique violations\n            raise DatabaseError(\n                f\"Unique constraint violated (not slug): {error_str}\"\n            ) from exc\n    except (\n        NotFoundError,\n        store_exceptions.ListingExistsError,\n    ):\n        raise\n    except prisma.errors.PrismaError as e:\n        logger.error(f\"Database error creating store submission: {e}\")\n        raise DatabaseError(\"Failed to create store submission\") from e\n\n\nasync def edit_store_submission(\n    user_id: str,\n    store_listing_version_id: str,\n    name: str,\n    video_url: str | None = None,\n    agent_output_demo_url: str | None = None,\n    image_urls: list[str] = [],\n    description: str = \"\",\n    sub_heading: str = \"\",\n    categories: list[str] = [],\n    changes_summary: str | None = \"Update submission\",\n    recommended_schedule_cron: str | None = None,\n    instructions: str | None = None,\n    organization_id: str | None = None,\n) -> store_model.StoreSubmission:\n    \"\"\"","sourceCodeStart":1008,"sourceCodeEnd":1044,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/store/db.py#L1008-L1044","documentation":"Generic wrapper: any prisma.errors.PrismaError raised during create_store_submission that is not a UniqueViolationError, NotFoundError, or ListingExistsError is logged ('Database error creating store submission') and re-raised as this DatabaseError. This is the residual bucket — connectivity loss mid-transaction, FK violations on categories/relations, data too long for columns, etc.","triggerScenarios":"FK violation when submitting with a category name that doesn't exist in the Category table; connection drop during the transaction; a field exceeding its column length (very long slugs/names after sanitization); transaction timeout.","commonSituations":"Frontend sending category labels instead of existing category IDs; stale category list in the UI after categories were renamed; flaky DB connection in CI.","solutions":["Inspect the chained PrismaError in server logs to identify the concrete cause (P2003 FK, P2028 timeout, etc.).","For P2003: fetch fresh categories from the store API and send only valid ones.","For timeouts/connectivity: verify DB health and retry once; check transaction timeout settings.","For length issues, trim user inputs client-side to sane limits."],"exampleFix":"// before\nawait api.createSubmission({ ...payload, categories: selectedCategoryLabels });\n// after\nconst valid = await api.getCategories();\nconst ids = selectedCategoryLabels.map(l => valid.find(c => c.name === l)?.id).filter(Boolean);\nawait api.createSubmission({ ...payload, categories: ids });","handlingStrategy":"try-catch","validationCode":"const validCategories = await api.getCategories();\nconst validNames = new Set(validCategories.map(c => c.name));\npayload.categories = payload.categories.filter(c => validNames.has(c));","typeGuard":null,"tryCatchPattern":"from backend.util.exceptions import DatabaseError\n\ntry:\n    await store_db.create_store_submission(...)\nexcept DatabaseError as e:\n    cause = e.__cause__\n    if getattr(cause, 'code', None) == 'P2003':\n        ui.show('One of the selected categories no longer exists — refresh and retry');\n    elif getattr(cause, 'code', None) == 'P2028':\n        retry_once()\n    else:\n        raise","preventionTips":["Fetch categories at submission time, not from page-load cache.","Inspect the chained PrismaError code (P2003 FK, P2028 timeout) to route handling.","Trim long text fields client-side to column limits."],"tags":["database","prisma","submission","store","error-wrapping"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}