Significant-Gravitas/AutoGPT · error · HTTPException

Failed to store credentials

Error message

Failed to store credentials

What it means

Raised (HTTP 500) when `creds_manager.create(auth.user_id, credentials)` throws while persisting a newly built credential. The original exception is logged with traceback (`logger.exception("Failed to store credentials")`); the HTTP detail deliberately hides the cause, so backend logs are required to diagnose it.

Source

Thrown at autogpt_platform/backend/backend/api/external/v1/integrations.py:589

        secret_headers = {k: SecretStr(v) for k, v in request.headers.items()}
        credentials = HostScopedCredentials(
            provider=provider,
            host=request.host,
            headers=secret_headers,
            title=request.title,
        )
    else:
        raise HTTPException(
            status_code=status.HTTP_400_BAD_REQUEST,
            detail=f"Unsupported credential type: {request.type}",
        )

    # Store credentials
    try:
        await creds_manager.create(auth.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",
        )

    logger.info(f"Created {request.type} credentials for provider {provider}")

    return CreateCredentialResponse(
        id=credentials.id,
        provider=provider,
        type=credentials.type,
        title=credentials.title,
    )


class DeleteCredentialResponse(BaseModel):
    """Response model for deleting a credential."""

    deleted: bool = Field(..., description="Whether the credential was deleted")

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Inspect backend logs for the `Failed to store credentials` traceback — it names the real storage error.
  2. Verify the database and Redis are up and migrated: `docker compose up -d` then `poetry run prisma migrate deploy` in the backend.
  3. Retry the request after fixing the underlying storage issue; the failure occurs before any state is committed for this credential.
  4. If the traceback shows a schema/constraint error, update the backend code and DB schema to matching versions.
Defensive patterns

Strategy: retry

Try / catch

try:
    client.post(f"/integrations/{provider}/credentials", json=body)
except HTTPError as e:
    if e.response.status_code == 500 and "store credentials" in e.response.text:
        wait_for_backend_healthy()  # DB/Redis check
        client.post(f"/integrations/{provider}/credentials", json=body)  # safe: nothing was committed
    else:
        raise

Prevention

When it happens

Trigger: POST `/integrations/{provider}/credentials` with a valid body, but the credentials store fails — most commonly a database outage/migration mismatch, a Redis lock failure, or a constraint violation (e.g. duplicate credential id / schema drift between the Credentials model and the DB).

Common situations: Postgres not running or unreachable after a docker-compose restart; prisma migrations not applied after pulling new code; Redis (used for user-integration locks) down; intermittent DB connection pool exhaustion under load.

Related errors


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