Skip to content

client-v2 HTTP auth: fix null password being sent as "null" string#2809

Merged
chernser merged 1 commit into
ClickHouse:mainfrom
buildkite:empty-password-not-null-string
Apr 1, 2026
Merged

client-v2 HTTP auth: fix null password being sent as "null" string#2809
chernser merged 1 commit into
ClickHouse:mainfrom
buildkite:empty-password-not-null-string

Conversation

@pda

@pda pda commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Summary

When no password is set on the v2 HTTP client, PASSWORD config returns null and Java string concatenation turns that into "null" producing default:null instead of default: in the Authorization header. This causes authentication failures against ClickHouse servers expecting an empty password. e.g. the official docker image running with CLICKHOUSE_SKIP_USER_SETUP.

Add a null check to treat missing passwords as empty string, matching the existing behavior in the v1 HTTP client. Add a WireMock-based test to verify the correct Authorization header is sent.

Checklist

Delete items not relevant to your PR:

  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG

When no password is set on the v2 HTTP client, PASSWORD config returns
null and Java string concatenation produces "default:null" instead of
"default:" in the Authorization header. This causes authentication
failures against ClickHouse servers expecting an empty password. e.g.
the official docker image running with CLICKHOUSE_SKIP_USER_SETUP.

Add a null check to treat missing passwords as empty string, matching
the existing behavior in the v1 HTTP client. Add a WireMock-based test
to verify the correct Authorization header is sent.
@pda pda requested review from chernser and mzitnik as code owners March 30, 2026 05:39
@CLAassistant

CLAassistant commented Mar 30, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes v2 HTTP Basic authentication when no password is configured by ensuring a missing password is treated as an empty string (so the Authorization header encodes default: instead of default:null), matching v1 behavior and preventing auth failures against servers expecting an empty password.

Changes:

  • Treat null password as "" when building the HTTP Basic Authorization header in the v2 client.
  • Add a WireMock-backed integration test asserting the correct Basic auth header is sent when no password is set.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
client-v2/src/main/java/com/clickhouse/client/api/internal/HttpAPIClientHelper.java Fixes Basic auth header construction to avoid encoding a null password as the literal "null".
client-v2/src/test/java/com/clickhouse/client/HttpTransportTests.java Adds an integration test validating the Basic auth header uses an empty password when unset.

@chernser chernser merged commit 7da2d78 into ClickHouse:main Apr 1, 2026
16 of 18 checks passed
@chernser

chernser commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

@pda

Thank you for the contribution!

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