BerriAI/litellm · error · ValueError

Databricks App OAuth token response returned non-object JSON

Error message

Databricks App OAuth token response returned non-object JSON (got {type(body).__name__})

What it means

Raised in the Databricks App OAuth flow when the token endpoint returned 2xx and response.json() succeeded, but the decoded body is not a JSON object (type name is embedded). The client expects a dict to extract access_token; a non-object body means the token_url likely points at the wrong endpoint or a gateway returned unexpected JSON.

Source

Thrown at litellm/proxy/agent_endpoints/databricks_oauth.py:196

                data={
                    "grant_type": "client_credentials",
                    "scope": config.scope,
                },
                headers={
                    "Authorization": f"Basic {basic_auth}",
                    "Content-Type": "application/x-www-form-urlencoded",
                },
            )
        except httpx.HTTPStatusError as exc:
            raise ValueError(
                f"Databricks App OAuth token request failed with status {exc.response.status_code}"
            ) from exc
        except httpx.HTTPError as exc:
            raise ValueError(f"Databricks App OAuth token request failed: {exc}") from exc

        body: Final = response.json()
        if not isinstance(body, dict):
            raise ValueError(
                f"Databricks App OAuth token response returned non-object JSON (got {type(body).__name__})"
            )

        access_token: Final = body.get("access_token")
        if not access_token:
            raise ValueError("Databricks App OAuth token response missing 'access_token'")

        raw_expires_in: Final = body.get("expires_in")
        try:
            expires_in = int(raw_expires_in) if raw_expires_in is not None else _DEFAULT_TTL_SECONDS
        except (TypeError, ValueError):
            expires_in = _DEFAULT_TTL_SECONDS

        ttl: Final = max(expires_in - _TOKEN_EXPIRY_BUFFER_SECONDS, 0)
        return access_token, ttl


databricks_app_oauth_token_cache: Final = DatabricksAppOAuthTokenCache()

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Inspect the token endpoint response; it must return a JSON object.

Example fix

Log the raw token response body.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at litellm/proxy/agent_endpoints/databricks_oauth.py:196 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/3105ee4a30fab1f1. Report an issue: GitHub.