Skip to content

Report token endpoint errors as connector errors - #356

Merged
nineinchnick merged 3 commits into
mainfrom
token-endpoint-errors
Oct 24, 2026
Merged

nineinchnick merged 3 commits into
mainfrom
token-endpoint-errors

Conversation

@nineinchnick

@nineinchnick nineinchnick commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

When the token endpoint failed, queries failed with exceptions of the HTTP client, like UnexpectedResponseException or OAuth2TokenException, which Trino reports as generic internal errors, without the request context that failures of requests to the API include. The exception type also depended on which of the two token providers from #337 got the token.

Error responses are now reported as OPENAPI_HTTP_ERROR with the status, and transport errors as OPENAPI_CONNECTION_ERROR, for both providers, for getting and for refreshing a token. The response body is never included, because token endpoints can repeat the client secret or the password sent in the token request, and the token URL is named without its query string for the same reason. Retries of token requests done by Airlift's provider don't change, so only their last failure is reported.

Making OpenApiClient.withoutQuery public is a separate commit, because the token providers are in another package.

The test of #350 for a 401 token response without a challenge now expects OPENAPI_HTTP_ERROR instead of the Airlift exception types.

Fixes #351

Requests to the token endpoint are sent from the authentication
package, and their failures need to name the token URL without its
query string, which can hold credentials, like failures of requests to
the API and to the spec location do.
When the token endpoint failed, queries failed with exceptions of the
HTTP client, like UnexpectedResponseException or OAuth2TokenException,
which Trino reports as generic internal errors, without the request
context that failures of requests to the API include. The exception
type also depended on which of the two token providers got the token.

Error responses are reported with the status, but without the response
body, because token endpoints can repeat the client secret or the
password sent in the token request, and the token URL is named without
its query string for the same reason. Retries of token requests done by
the providers don't change, so only their last failure is reported.
Both token providers need to report error responses, connection
failures, and failures of refreshing a rejected token with connector
error codes, without leaking the client secret, the password, or the
response body into the error.
@nineinchnick
nineinchnick force-pushed the token-endpoint-errors branch from 8e52be9 to 7e20103 Compare October 24, 2026 15:59
@nineinchnick
nineinchnick merged commit 3ff147c into main Oct 24, 2026
1 check passed
@nineinchnick
nineinchnick deleted the token-endpoint-errors branch October 24, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Report token endpoint errors as connector errors

1 participant