{"record":{"id":"0739ab33ef4cbddb","repo":"Significant-Gravitas/AutoGPT","slug":"failed-to-store-credentials-0739ab","errorCode":null,"errorMessage":"Failed to store credentials","messagePattern":"Failed to store credentials","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"critical","filePath":"autogpt_platform/backend/backend/api/features/integrations/router.py","lineNumber":593,"sourceCode":"    if provider == ProviderName.CODEX:\n        raise HTTPException(\n            status_code=status.HTTP_400_BAD_REQUEST,\n            detail=\"Codex credentials must be created through ChatGPT sign-in\",\n        )\n    if (\n        isinstance(credentials, OAuth2Credentials)\n        and credentials.refresh_strategy == \"provider_runtime\"\n    ):\n        raise HTTPException(\n            status_code=status.HTTP_400_BAD_REQUEST,\n            detail=\"Provider-runtime credentials cannot be created directly\",\n        )\n    credentials.provider = provider\n    try:\n        await creds_manager.create(user_id, credentials)\n    except Exception:\n        logger.exception(\"Failed to store credentials\")\n        raise HTTPException(\n            status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,\n            detail=\"Failed to store credentials\",\n        )\n    return to_meta_response(credentials)\n\n\nclass CredentialsDeletionResponse(BaseModel):\n    deleted: Literal[True] = True\n    revoked: bool | None = Field(\n        description=\"Indicates whether the credentials were also revoked by their \"\n        \"provider. `None`/`null` if not applicable, e.g. when deleting \"\n        \"non-revocable credentials such as API keys.\"\n    )\n\n\nclass CredentialsDeletionNeedsConfirmationResponse(BaseModel):\n    deleted: Literal[False] = False\n    need_confirmation: Literal[True] = True","sourceCodeStart":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/integrations/router.py#L575-L611","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check backend logs for the 'Failed to store credentials' exception — it carries the root cause","Verify Postgres is reachable and migrations are applied (poetry run prisma migrate dev)","If duplicate ID: omit the id field and let the server assign a uuid4","Retry once after infrastructure is healthy"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if resp.status_code == 500:\n    log_server_exception()  # correlate via timestamp\n    await asyncio.sleep(1)\n    resp = await retry_once(client.post, url, json=payload)  # only after infra check\nresp.raise_for_status()","preventionTips":["Surface the server-side exception id/log to whoever debugs — the HTTP detail is intentionally generic","Never client-assign ids that can collide"],"tags":["credentials","database","storage","http-500"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}