Significant-Gravitas/AutoGPT · critical · DatabaseError

StoreListing {listing.id} has no CreatorProfile — FK violate

Error message

StoreListing {listing.id} has no CreatorProfile — FK violated

What it means

Raised by get_store_agent_details when a StoreListing row's CreatorProfile relation is None. The schema declares CreatorProfile as a required FK on StoreListing, so a None relation means the database is in a corrupt or inconsistent state (e.g. the creator row was deleted without cascading, or data was imported/migrated without the relation). It is wrapped as DatabaseError, which the API layer surfaces as a 500-class failure. This is not caused by bad user input; it signals a data-integrity break between StoreListing and Creator/Profile.

Source

Thrown at autogpt_platform/backend/backend/api/features/store/db.py:441

    StoreAgent view. Queries StoreListingVersion directly so pending
    submissions are visible."""
    slv = await prisma.models.StoreListingVersion.prisma().find_unique(
        where={"id": store_listing_version_id},
        include={
            "StoreListing": {"include": {"CreatorProfile": True}},
        },
    )
    if not slv or not slv.StoreListing:
        raise NotFoundError(
            f"Store listing version {store_listing_version_id} not found"
        )

    listing = slv.StoreListing
    # CreatorProfile is a required FK relation — should always exist.
    # If it's None, the DB is in a bad state.
    profile = listing.CreatorProfile
    if not profile:
        raise DatabaseError(
            f"StoreListing {listing.id} has no CreatorProfile — FK violated"
        )

    return store_model.StoreAgentDetails(
        store_listing_version_id=slv.id,
        slug=listing.slug,
        agent_name=slv.name,
        agent_video=slv.videoUrl or "",
        agent_output_demo=slv.agentOutputDemoUrl or "",
        agent_image=slv.imageUrls,
        creator=profile.username,
        creator_avatar=profile.avatarUrl or "",
        sub_heading=slv.subHeading,
        description=slv.description,
        instructions=slv.instructions,
        categories=slv.categories,
        runs=0,
        rating=0.0,

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Run an integrity query: SELECT id FROM "StoreListing" sl LEFT JOIN "Profile" p ON p."userId" = sl."submissionAgentId" WHERE p."userId" IS NULL (adjust to the actual FK column) to find orphan listings.
  2. Restore the missing Creator/Profile row, or delete/recreate the orphaned StoreListing and its versions.
  3. Verify the Prisma schema's relation and the underlying SQL FK constraint (ON DELETE RESTRICT or CASCADE) so future creator deletions cannot orphan listings.
  4. If this fires across many listings after a migration, roll back the migration and re-run it with the correct relation data.

Example fix

// before: orphan listing left in DB after creator deletion
DELETE FROM "Profile" WHERE "userId" = 'usr_123'; -- leaves StoreListing.CreatorProfile dangling
// after: remove dependent listings atomically, or block the delete
BEGIN;
DELETE FROM "StoreListingVersion" WHERE "storeListingId" IN (SELECT id FROM "StoreListing" WHERE "submissionAgentId" = 'usr_123');
DELETE FROM "StoreListing" WHERE "submissionAgentId" = 'usr_123';
DELETE FROM "Profile" WHERE "userId" = 'usr_123';
COMMIT;
Defensive patterns

Strategy: try-catch

Try / catch

from backend.util.exceptions import DatabaseError

try:
    details = await store_db.get_store_agent_details(version_id)
except DatabaseError as e:
    if 'no CreatorProfile' in str(e):
        logger.critical('Data integrity: orphan StoreListing %s', version_id)
        raise StoreIntegrityAlert(version_id) from e
    raise

Prevention

When it happens

Trigger: Calling the store agent details endpoint (GET /store/search/agents or the details route that resolves a store_listing_version_id) for a listing whose CreatorProfile relation resolves to None. Typically happens after a Creator/Profile row was manually deleted via SQL, after a partial prisma migrate, or after seeding StoreListing rows without their creator relation.

Common situations: Manual DB cleanup scripts that delete Profile or Creator rows referenced by StoreListing; FK constraints disabled or ON DELETE behavior changed in a migration; test fixtures that create StoreListing without CreatorProfile; env mismatch where the app points at a stale/dirty database snapshot.

Related errors


AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14). Data as JSON: /api/errors/c109d5dfe9364db7. Report an issue: GitHub.