Significant-Gravitas/AutoGPT · critical · HTTPException

Failed to store credentials

Error message

Failed to store credentials

What it means

POST /integrations/{provider}/credentials returns 500 'Failed to store credentials' when creds_manager.create(user_id, credentials) raises any exception. The original exception is logged server-side (logger.exception 'Failed to store credentials') but only a generic 500 is returned, so the server log is the source of the real cause.

Source

Thrown at autogpt_platform/backend/backend/api/features/integrations/router.py:593

    if provider == ProviderName.CODEX:
        raise HTTPException(
            status_code=status.HTTP_400_BAD_REQUEST,
            detail="Codex credentials must be created through ChatGPT sign-in",
        )
    if (
        isinstance(credentials, OAuth2Credentials)
        and credentials.refresh_strategy == "provider_runtime"
    ):
        raise HTTPException(
            status_code=status.HTTP_400_BAD_REQUEST,
            detail="Provider-runtime credentials cannot be created directly",
        )
    credentials.provider = provider
    try:
        await creds_manager.create(user_id, credentials)
    except Exception:
        logger.exception("Failed to store credentials")
        raise HTTPException(
            status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
            detail="Failed to store credentials",
        )
    return to_meta_response(credentials)


class CredentialsDeletionResponse(BaseModel):
    deleted: Literal[True] = True
    revoked: bool | None = Field(
        description="Indicates whether the credentials were also revoked by their "
        "provider. `None`/`null` if not applicable, e.g. when deleting "
        "non-revocable credentials such as API keys."
    )


class CredentialsDeletionNeedsConfirmationResponse(BaseModel):
    deleted: Literal[False] = False
    need_confirmation: Literal[True] = True

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Check backend logs for the 'Failed to store credentials' exception — it carries the root cause
  2. Verify Postgres is reachable and migrations are applied (poetry run prisma migrate dev)
  3. If duplicate ID: omit the id field and let the server assign a uuid4
  4. Retry once after infrastructure is healthy
Defensive patterns

Strategy: retry

Try / catch

if resp.status_code == 500:
    log_server_exception()  # correlate via timestamp
    await asyncio.sleep(1)
    resp = await retry_once(client.post, url, json=payload)  # only after infra check
resp.raise_for_status()

Prevention

When it happens

Trigger: POST /credentials while the credentials store is unavailable: DB connection failure, prisma error, Redis down (if cached), constraint violation (duplicate id), or an encryption/serialization error on the secret fields.

Common situations: Database container not up or migrations not applied (docker compose up -d / prisma migrate dev); duplicate ID from client-assigned ids; secret-encryption key mismatch after re-keying; transient DB outage.

Related errors


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