Skip to content

[ZEPPELIN-6475] Throw clear error for missing InfluxDB token#5301

Open
gyowoo1113 wants to merge 2 commits into
apache:masterfrom
gyowoo1113:ZEPPELIN-6475-handle-missing-influxdb-token
Open

[ZEPPELIN-6475] Throw clear error for missing InfluxDB token#5301
gyowoo1113 wants to merge 2 commits into
apache:masterfrom
gyowoo1113:ZEPPELIN-6475-handle-missing-influxdb-token

Conversation

@gyowoo1113

Copy link
Copy Markdown

What is this PR for?

InfluxDBInterpreter.open() read the influxdb.token property and immediately called toCharArray() on the returned value. When the token was not configured, getProperty(...) returned null, causing a NullPointerException without explaining that the authentication token was missing.

This PR validates the token before building the InfluxDB client. Missing, empty, and blank token values now throw an InterpreterException with a clear configuration message instead of a NullPointerException.

Unit tests were added for absent, empty, and whitespace-only token values. Other InfluxDB properties and client creation behavior are unchanged.

What type of PR is it?

Bug Fix

Todos

  • Validate missing, empty, and blank influxdb.token values
  • Throw InterpreterException with a clear error message
  • Add unit tests for each invalid token case

What is the Jira issue?

ZEPPELIN-6475

How should this be tested?

./mvnw test -pl influxdb passes successfully.

To run only the interpreter test:

./mvnw test -pl influxdb -Dtest=InfluxDBInterpeterTest passes successfully.

Missing, empty, and blank influxdb.token values throw InterpreterException instead of NullPointerException.

Screenshots (if appropriate)

N/A

Questions:

  • Does the license files need to update? No
  • Is there breaking changes for older versions? No
  • Does this needs documentation? No

@hyunw9 hyunw9 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


if (this.client == null) {
String token = getProperty(INFLUXDB_TOKEN_PROPERTY);
if (token == null || token.trim().isEmpty()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit :
How about token.isBlank() instead? it covers same situations but it reads more clearly.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, thanks! I’ve updated it to use isBlank().

jongyoul
jongyoul previously approved these changes Jul 15, 2026

@ParkGyeongTae ParkGyeongTae left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this, @gyowoo1113! I pulled the branch and verified locally:

  • Confirmed the NPE reproduces on master when influxdb.token is unset (getProperty(...).toCharArray() on a null value).
  • The open() signature change to throws InterpreterException is safe — the parent Interpreter.open() already declares throws InterpreterException, so no callers are affected.
  • String.isBlank() is fine here since the project targets Java 11.
  • Ran ./mvnw test -pl influxdb -Dtest=InfluxDBInterpeterTest: all 5 tests pass (2 existing + 3 new for missing/empty/blank token).

@ParkGyeongTae ParkGyeongTae self-assigned this Jul 15, 2026
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.

4 participants