{"record":{"id":"34bd33cf83c9ac89","repo":"Significant-Gravitas/AutoGPT","slug":"unsupported-credential-type-request-type","errorCode":null,"errorMessage":"Unsupported credential type: {request.type}","messagePattern":"Unsupported credential type: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"autogpt_platform/backend/backend/api/external/v1/integrations.py","lineNumber":579,"sourceCode":"        )\n    elif request.type == \"user_password\":\n        credentials = UserPasswordCredentials(\n            provider=provider,\n            username=SecretStr(request.username),\n            password=SecretStr(request.password),\n            title=request.title,\n        )\n    elif request.type == \"host_scoped\":\n        # Convert string headers to SecretStr\n        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,","sourceCodeStart":561,"sourceCodeEnd":597,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/external/v1/integrations.py#L561-L597","documentation":"Raised (HTTP 400) by the external create-credentials endpoint when `request.type` (a discriminated union field) is not one of `\"api_key\"`, `\"user_password\"`, or `\"host_scoped\"`. The request model uses a discriminated union, so in practice FastAPI's own 422 validation usually catches bad types first; this branch is a defensive backstop for any payload that passes parsing without a supported type.","triggerScenarios":"POST `/integrations/{provider}/credentials` with `\"type\": \"oauth\"`, `\"type\": \"bearer\"`, a typo like `\"apikey\"`, or an omitted/misnamed discriminator in the JSON body (the latter typically yields 422 instead).","commonSituations":"Assuming OAuth credentials can be created here (they must go through initiate/complete); new credential types added in a newer platform version being sent to an older backend; hand-built JSON payloads with wrong discriminator values.","solutions":["Use one of the supported types: `api_key`, `user_password`, or `host_scoped` with the matching body fields.","For OAuth providers, use the `/oauth/authorize` + `/oauth/callback` flow instead of this endpoint.","Upgrade the platform if you need a credential type introduced in a newer version."],"exampleFix":"# before\nPOST /integrations/github/credentials {\"type\": \"oauth\", \"access_token\": \"...\"}  # 400/422\n\n# after\nPOST /integrations/github/credentials {\"type\": \"api_key\", \"api_key\": \"ghp_...\", \"title\": \"CI token\"}","handlingStrategy":"type-guard","validationCode":"SUPPORTED = {\"api_key\", \"user_password\", \"host_scoped\"}\nassert body[\"type\"] in SUPPORTED, f\"type must be one of {SUPPORTED}\",\nclient.post(f\"/integrations/{provider}/credentials\", json=body)","typeGuard":"from typing import TypedDict\n\nclass ApiKeyBody(TypedDict):\n    type: str  # literal \"api_key\"\n    api_key: str\n    title: str | None\n\ndef is_api_key_body(b: dict) -> bool:\n    return b.get(\"type\") == \"api_key\" and isinstance(b.get(\"api_key\"), str)","tryCatchPattern":"try:\n    client.post(f\"/integrations/{provider}/credentials\", json=body)\nexcept HTTPError as e:\n    if e.response.status_code in (400, 422) and \"credential type\" in e.response.text:\n        raise ValueError(f\"use api_key|user_password|host_scoped; OAuth goes via /oauth/*\") from e\n    raise","preventionTips":["Build request bodies from the discriminated-union schema: type decides required fields.","Route OAuth providers to the authorize/complete flow, never to create-credentials."],"tags":["credentials","validation","discriminated-union","bad-request"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}