Significant-Gravitas/AutoGPT · warning · HTTPException

Credential to upgrade not found

Error message

Credential to upgrade not found

What it means

In _prepare_scope_upgrade, after passing the system-credential check, the existing credential is fetched with creds_manager.store.get_creds_by_id(user_id, credential_id). If the lookup returns nothing (wrong ID, deleted credential, or credential owned by a different user), HTTP 404 'Credential to upgrade not found' is raised.

Source

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

    For providers without native incremental auth (e.g. GitHub), returns the
    union of existing + requested scopes.  For providers that handle merging
    server-side (e.g. Google with ``include_granted_scopes``), returns the
    requested scopes unchanged.

    Raises HTTPException on validation failure.
    """
    # Platform-owned system credentials must never be upgraded — scope
    # changes here would leak across every user that shares them.
    if is_system_credential(credential_id):
        raise HTTPException(
            status_code=status.HTTP_400_BAD_REQUEST,
            detail="System credentials cannot be upgraded",
        )

    existing = await creds_manager.store.get_creds_by_id(user_id, credential_id)
    if not existing:
        raise HTTPException(
            status_code=status.HTTP_404_NOT_FOUND,
            detail="Credential to upgrade not found",
        )
    if not isinstance(existing, OAuth2Credentials):
        raise HTTPException(
            status_code=status.HTTP_400_BAD_REQUEST,
            detail="Only OAuth2 credentials can be upgraded",
        )
    if not provider_matches(existing.provider, provider.value):
        raise HTTPException(
            status_code=status.HTTP_400_BAD_REQUEST,
            detail="Credential provider does not match the requested provider",
        )
    if existing.is_managed:
        raise HTTPException(
            status_code=status.HTTP_400_BAD_REQUEST,
            detail="Managed credentials cannot be upgraded",
        )

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Re-fetch the user's credential list (GET /integrations/{provider}/credentials) and confirm the ID is present before retrying.
  2. If the credential was deleted, re-authenticate the provider to create a fresh credential, then request the desired scopes during that flow.
  3. Ensure the authenticated user matches the credential owner — the lookup is scoped by user_id.
  4. Confirm frontend and backend point at the same environment so IDs resolve.
Defensive patterns

Strategy: validation

Validate before calling

# Confirm the credential exists before starting the upgrade flow
creds = (await client.get(f"/integrations/{provider}/credentials")).json()
if credential_id not in {c["id"] for c in creds}:
    refresh_credential_list()  # stale state — don't call the upgrade/login API

Prevention

When it happens

Trigger: Initiating a scope upgrade for a credential_id that was deleted (revoked/expired cleanup) between listing and clicking upgrade; passing an ID from another user or another environment; typo/mangled ID in the request.

Common situations: Stale frontend state after the user deleted the connection in another tab; environment mismatch (dev frontend talking to prod backend); credential ID truncated when passed through a URL or log.

Related errors


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