Significant-Gravitas/AutoGPT · error · DatabaseError

Unique constraint violated (not slug): {error_str}

Error message

Unique constraint violated (not slug): {error_str}

What it means

DatabaseError raised when the insert hits a UniqueViolationError whose message does not contain 'slug'. The store schema has several unique constraints — notably StoreListing.agentGraphId (one listing per agent) and StoreListingVersion composite keys — so this usually means a listing already exists for that agent graph, or a version-key collision. The raw Postgres error text is embedded in the message, which tells you the exact constraint name.

Source

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

            )

        if not new_submission:
            raise DatabaseError("Failed to create store listing version")

        logger.debug(f"Created store listing for agent {graph_id}")
        return store_model.StoreSubmission.from_listing_version(new_submission)
    except prisma.errors.UniqueViolationError as exc:
        # Attempt to check if the error was due to the slug field being unique
        error_str = str(exc)
        if "slug" in error_str.lower():
            logger.debug(f"Slug '{slug}' is already in use by graph #{graph_id}")
            raise store_exceptions.SlugAlreadyInUseError(
                f"The slug '{slug}' is already in use by another one of your agents. "
                "Please choose a different slug."
            ) from exc
        else:
            # Reraise as a generic database error for other unique violations
            raise DatabaseError(
                f"Unique constraint violated (not slug): {error_str}"
            ) from exc
    except (
        NotFoundError,
        store_exceptions.ListingExistsError,
    ):
        raise
    except prisma.errors.PrismaError as e:
        logger.error(f"Database error creating store submission: {e}")
        raise DatabaseError("Failed to create store submission") from e


async def edit_store_submission(
    user_id: str,
    store_listing_version_id: str,
    name: str,
    video_url: str | None = None,
    agent_output_demo_url: str | None = None,

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Read the constraint name in the message (e.g. 'StoreListing_agentGraphId_key') to identify the collision.
  2. If the listing already exists, use the edit/submission-update flow (edit_store_submission) instead of creating a new listing.
  3. Guard the UI against double submits; on retry-after-timeout, first GET the agent's submissions to see if it already exists.
  4. For version collisions, recompute the next version number from the latest listing version instead of a client-supplied value.

Example fix

// before
await api.createSubmission(payload); // retried blindly after timeout
// after
const existing = await api.getMySubmissions().then(s => s.find(x => x.agent_id === payload.graph_id));
if (existing) await api.editSubmission(existing.store_listing_version_id, payload);
else await api.createSubmission(payload);
Defensive patterns

Strategy: try-catch

Validate before calling

const existing = await api.getMySubmissions()
  .then(list => list.find(s => s.agent_id === payload.graph_id));
if (existing) {
  await api.editSubmission(existing.store_listing_version_id, payload);
} else {
  await api.createSubmission(payload);
}

Try / catch

from backend.api.features.store import store_exceptions
from backend.util.exceptions import DatabaseError

try:
    await store_db.create_store_submission(...)
except store_exceptions.SlugAlreadyInUseError:
    ui.show('Choose a different slug');
except DatabaseError as e:
    if 'Unique constraint violated' in str(e):
        ui.refreshSubmissions()  # listing likely already exists; switch to edit flow
    else:
        raise

Prevention

When it happens

Trigger: POST /store/submissions for an agent that already has a StoreListing while the code path attempts create (instead of the existing-listing update path); concurrent double submission both passing the exists-check and racing the insert; retrying a request whose first attempt actually committed.

Common situations: Publishing the same agent twice quickly; a network timeout on the first POST that actually succeeded, followed by a client retry; ListingExistsError check bypassed due to stale state.

Related errors


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