{"record":{"id":"f4128c603c5173e9","repo":"Significant-Gravitas/AutoGPT","slug":"failed-to-create-store-listing-version","errorCode":null,"errorMessage":"Failed to create store listing version","messagePattern":"Failed to create store listing version","errorType":"exception","errorClass":"DatabaseError","httpStatus":500,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/store/db.py","lineNumber":1001,"sourceCode":"                                # scalar: this nested create uses checked\n                                # (relation) input syntax, and Prisma\n                                # rejects the whole create when a raw FK\n                                # field is mixed in (\"Field does not exist\n                                # in enclosing type\").\n                                **(\n                                    {\"OwningOrg\": {\"connect\": {\"id\": organization_id}}}\n                                    if organization_id\n                                    else {}\n                                ),\n                            },\n                        }\n                    },\n                },\n                include={\"StoreListing\": True},\n            )\n\n        if not new_submission:\n            raise DatabaseError(\"Failed to create store listing version\")\n\n        logger.debug(f\"Created store listing for agent {graph_id}\")\n        return store_model.StoreSubmission.from_listing_version(new_submission)\n    except prisma.errors.UniqueViolationError as exc:\n        # Attempt to check if the error was due to the slug field being unique\n        error_str = str(exc)\n        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 (","sourceCodeStart":983,"sourceCodeEnd":1019,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/store/db.py#L983-L1019","documentation":"DatabaseError raised when the StoreListingVersion create() inside the submission transaction returns None. Prisma's create returning None (rather than raising) happens when the write is affected by the surrounding transaction state or the client cannot confirm the row; combined with the UniqueViolationError handler below, this is the 'create did not produce a row for an unexpected reason' branch of create_store_submission.","triggerScenarios":"The transaction context (async with transaction() as tx) aborts or the create is rolled back by a nested await failure; race where two submissions for the same agent interleave and one transaction is invalidated; prisma client version returning None on conflict inside interactive transactions.","commonSituations":"Double-click on Publish firing two concurrent submissions; retry logic racing the original request; interactive-transaction timeouts under slow DB load.","solutions":["Check server logs for the surrounding PrismaError — the None return usually accompanies an aborted transaction.","Debounce/disable the publish button while a submission is in flight to prevent concurrent duplicates.","If persistent, reproduce with logging around the create call and verify the transaction helper's isolation/timeout settings."],"exampleFix":"// before\n<button onClick={() => publish()}>Publish</button>\n// after\nconst [busy, setBusy] = useState(false);\n<button disabled={busy} onClick={() => { setBusy(true); publish().finally(() => setBusy(false)); }}>Publish</button>;","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from backend.util.exceptions import DatabaseError\n\ntry:\n    sub = await store_db.create_store_submission(...)\nexcept DatabaseError as e:\n    if 'Failed to create store listing version' in str(e):\n        existing = await get_existing_submission(graph_id)  # did it commit anyway?\n        if existing: return existing\n        raise","preventionTips":["Prevent concurrent duplicate submissions in the UI (in-flight lock on publish).","After any ambiguous submission failure, check whether the listing was actually created before retrying.","Keep transaction scope short to reduce abort windows."],"tags":["database","transaction","submission","store","race-condition"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}