{"record":{"id":"45be3348f100c3af","repo":"Significant-Gravitas/AutoGPT","slug":"failed-to-store-credentials","errorCode":null,"errorMessage":"Failed to store credentials","messagePattern":"Failed to store credentials","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"autogpt_platform/backend/backend/api/external/v1/integrations.py","lineNumber":589,"sourceCode":"        secret_headers = {k: SecretStr(v) for k, v in request.headers.items()}\n        credentials = HostScopedCredentials(\n            provider=provider,\n            host=request.host,\n            headers=secret_headers,\n            title=request.title,\n        )\n    else:\n        raise HTTPException(\n            status_code=status.HTTP_400_BAD_REQUEST,\n            detail=f\"Unsupported credential type: {request.type}\",\n        )\n\n    # Store credentials\n    try:\n        await creds_manager.create(auth.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\n    logger.info(f\"Created {request.type} credentials for provider {provider}\")\n\n    return CreateCredentialResponse(\n        id=credentials.id,\n        provider=provider,\n        type=credentials.type,\n        title=credentials.title,\n    )\n\n\nclass DeleteCredentialResponse(BaseModel):\n    \"\"\"Response model for deleting a credential.\"\"\"\n\n    deleted: bool = Field(..., description=\"Whether the credential was deleted\")","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/external/v1/integrations.py#L571-L607","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Inspect backend logs for the `Failed to store credentials` traceback — it names the real storage error.","Verify the database and Redis are up and migrated: `docker compose up -d` then `poetry run prisma migrate deploy` in the backend.","Retry the request after fixing the underlying storage issue; the failure occurs before any state is committed for this credential.","If the traceback shows a schema/constraint error, update the backend code and DB schema to matching versions."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    client.post(f\"/integrations/{provider}/credentials\", json=body)\nexcept HTTPError as e:\n    if e.response.status_code == 500 and \"store credentials\" in e.response.text:\n        wait_for_backend_healthy()  # DB/Redis check\n        client.post(f\"/integrations/{provider}/credentials\", json=body)  # safe: nothing was committed\n    else:\n        raise","preventionTips":["Health-check the platform (DB + Redis reachable) before credential write batches.","Apply prisma migrations whenever backend code is updated.","On 500 here, check backend logs for the 'Failed to store credentials' traceback before retrying blindly."],"tags":["credentials","database","internal-server-error","storage"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}