Skip to content

Validate access_token and token_type in token endpoint responses#764

Open
renaudhartert-db wants to merge 2 commits intomainfrom
fix/issue-335-token-refresh-npe
Open

Validate access_token and token_type in token endpoint responses#764
renaudhartert-db wants to merge 2 commits intomainfrom
fix/issue-335-token-refresh-npe

Conversation

@renaudhartert-db
Copy link
Copy Markdown
Contributor

@renaudhartert-db renaudhartert-db commented Apr 16, 2026

Summary

  • When the OAuth token endpoint returns a 200 response without access_token or token_type, the SDK threw an opaque NPE in the Token constructor.
  • Added explicit validation in TokenEndpointClient at both requestToken() and retrieveToken(), throwing a DatabricksException that includes the endpoint URL for debuggability.

Test plan

  • Added 3 test cases in TokenEndpointClientTest (missing access_token, missing token_type, empty access_token)
  • Added 1 test case in EndpointTokenSourceTest (missing access_token in response)
  • All 22 token tests pass
  • Formatted with fmt-maven-plugin

Fixes #335

When a token endpoint returns 200 with no access_token or token_type,
the SDK would NPE in the Token constructor. This adds explicit
validation in both requestToken() and retrieveToken() that throws
DatabricksException with the endpoint URL for debuggability.

Co-authored-by: Isaac
@github-actions
Copy link
Copy Markdown
Contributor

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-java

Inputs:

  • PR number: 764
  • Commit SHA: 5412d678ae1494bf605bd86c4531ba1c4f7378ed

Checks will be approved automatically on success.

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.

[ISSUE] SDK throws null pointer exception when attempting to refresh tokens

1 participant