Skip to content

Add a test for default_session_user naming a user that is not declared in the users configuration - #117386

Merged
PedroTadim merged 2 commits into
ClickHouse:masterfrom
groeneai:test-undeclared-default-session-user
Sep 1, 2026
Merged

PedroTadim merged 2 commits into
ClickHouse:masterfrom
groeneai:test-undeclared-default-session-user

Conversation

@groeneai

@groeneai groeneai commented Aug 31, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

Related: #110179

Requested by @ fm4v: #110179 (comment)

tests/integration/test_default_session_user/ covered the setting naming a declared user, and the
empty-string reject mode, on every interface, but not a value naming a user absent from the users
configuration. The one existing nonexistent-user assertion, in test_native_default_session_user,
takes the name from the client in the native Hello, so nothing is substituted there and the setting
is not exercised.

Behaviour. The name is resolved through AccessControl, which also serves users created by SQL,
so a name absent from the users configuration is not necessarily invalid and is not checked at
configuration load; the only config-time check on the setting concerns the interserver protocol.
The server therefore starts, and the failure is deferred to connect time: the name is substituted for
the empty user name and then authenticated like any other, and AccessControl::authenticate reports
AUTHENTICATION_FAILED under the configured name, which HTTP answers with 403. That is the setting's
documented contract, an empty user name being merely an alias for the configured user name.

Change. The module's otherwise-idle node2 gets a global default_session_user naming a user
absent from configs/users.xml, and one test makes one anonymous HTTP request to it plus one
explicit-user control. node2 stops mounting configs/config.xml, whose endpoints nothing on that
node uses, keeping the cluster definition and the reload-interval pin its other two assertions need.

Validation. New test 20/20, full module 30/30. Pointing the setting at a declared user fails the
test, since the anonymous request then succeeds; pointing it at a different undeclared name fails the
name assertion while the 403 still holds, so the test pins the substituted name rather than merely
some authentication error.

The other interfaces reach the same failure through their own substitution sites and differ only in
how they report it, which is pre-existing and out of scope here.


Workflow [PR]
Sync PR [sync-upstream/pr/117386]

Version info

  • Merged into: 26.9.1.494 (included in 26.9 and later)

…d in the users configuration

`default_session_user` substitutes a configured user name whenever a client
connects without one. Its integration suite covered the setting naming a
declared user on every interface, and the empty-string reject mode on every
interface, but not the value naming a user that is absent from the users
configuration: the ordinary typo, and the state a server is in whenever the
shipped default `default` is used while the `default` user has been removed
from the users configuration. The one existing nonexistent-user assertion
supplies the name from the client in the native Hello, so no substitution
happens on that path and the setting is not exercised.

Nothing validates the name earlier. The only config-time check on the setting
concerns the interserver protocol, so the server starts normally and the
failure is deferred to connect time: the name is substituted for the empty
user name and then authenticated like any other, and
`AccessControl::authenticate` reports `AUTHENTICATION_FAILED` under the
configured name, which HTTP answers with 403. That is the setting's own
documented contract, an empty user name being merely an alias for the
configured user name, so the connection stays subject to the substituted
user's authentication.

The test points the global `default_session_user` of the module's
otherwise-idle `node2` at a name absent from `configs/users.xml` and makes one
anonymous HTTP request plus one explicit-user control. `node2` no longer mounts
`configs/config.xml`, whose endpoints nothing on that node uses; it keeps the
cluster definition the interserver test needs and the reload-interval pin the
fixture asserts.

Requested by @ fm4v in
ClickHouse#110179 (comment)

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Aug 31, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal review record (independent cold review + second-model gate, 0 blockers)

Kept short on purpose. No code change came out of it; the four accepted findings were all in the
pull request description, which the reviewing phase owns.

# finding verdict
1 Related: line for #110179 was inside the template's HTML comment, so it did not render accepted, moved into the description
2 description cited a line number for the pre-existing nonexistent-user assertion, which this diff shifts accepted, replaced with the test name
3 description was over the length budget accepted, condensed
4 commit subject leaves default_session_user un-backticked accepted for the title; the commit is not amended
5 add an explicit system.server_settings assertion on node2 declined: the asserted error message is built from the substituted name, so it cannot be produced unless the configured value was loaded and substituted
6 exercise more than one interface declined: the four HTTP authentication branches share one resolved value and one Session::authenticate call, the other interfaces differ only in how they report the same failure and already have declared-user and reject-mode coverage here, and native_hello reads one response byte so it could not discriminate the substituted name

Independently verified while reviewing, rather than taken from the change: node2 is referenced only
by its definition, the fixture's reload-interval assertion, this new test and the interserver test, so
dropping configs/config.xml from it removes nothing any test consumes; interserver cannot take the
substitution path (TCPHandler.cpp computes is_interserver_mode from
!user_substituted_by_default, and interserver HTTP does not reach authenticateUserByHTTP at all);
403 rather than 401 follows from AUTHENTICATION_FAILED in exceptionCodeToHTTPStatus.cpp, the 401
branch being REQUIRED_PASSWORD, which is reachable only for an empty or default name; and the new
config file is well-formed against a parser that rejects an unclosed root and a broken comment.

The second-model gate read both changed files, the whole module, the sibling configs, every node2
use, the fixture helpers and the HTTP authentication path, and reported nothing.

@clickhouse-gh

clickhouse-gh Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [21065be]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6) ERROR
Container memory budget exceeded (/docker) ERROR cidb IGNORED

AI Review

Summary

This test-only PR adds an integration case for a global default_session_user that names a user absent from configs/users.xml, and trims node2 down to the config surface that this new case and the existing interserver assertion actually use. I reviewed the full diff, the current test module, the relevant authentication code paths, the PR discussion, and the current CI reports, and I did not find a remaining correctness or coverage issue in the current head.

Missing context / blind spots
  • ⚠️ I did not re-run the integration module locally because this workspace does not contain a clickhouse server binary for ci.praktika or native integration runs. That gap is partly closed by the PR's current green CI reports.
Final Verdict

✅ No new findings.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 31, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @CheSema, could you review this? It is a test-only change covering the missing case where the default_session_user server setting names a user absent from the users configuration: the name is substituted for the empty user name in the HTTP handler and then fails authentication under that name, which the new integration case pins with a 403 plus an explicit-user control.

@groeneai

groeneai commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 93688f0c731a8bb85dbd5fe7306f3b50c7424a5e

Every failure below has an owner: a fixing PR, or a full-effort fix task whose fixing-PR link I will post here when it opens.

Check / test Reason Owner / fixing PR
Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6) / Container memory budget exceeded (/docker) host memory over-commit: the /docker cgroup leaf OOM-kills the nested containers and the whole shard loses its signal (244 PRs, 305 runs, 25 true-master hits in 7d) a fix task owns it at P1 (fixing PR link to follow here)

This is the only red and it is not caused by this PR. #117202 (merged) is already on this branch and the signature still fires, so ownership stays with the fix task.

Session id: cron:our-pr-ci-monitor:20260901-003000

@PedroTadim PedroTadim self-assigned this Sep 1, 2026
@PedroTadim
PedroTadim enabled auto-merge September 1, 2026 11:25
@groeneai

groeneai commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 21065bec651a2d810b74d17e4f67ec0632a493d0

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6) / Container memory budget exceeded (/docker) the shard's nested containers breach the /docker cgroup leaf, the kernel OOM-kills processes inside it and the job errors with no test attributed #117412 (external, merged 2026-09-01T11:31:33Z)

The /docker breach is a job-level condition, not a test result. I measured #117412 ABSENT from the tree that ran, from the job's own environment rather than from git ancestry: this job was launched with CI_DIND_INIT_RESERVE=17179869184 (the 16 GiB share #117412 replaces), and so were all ten failing legs I read this tick. The probe discriminates, with a positive control: two shards launched at 14:53Z and 14:59Z carry CI_DIND_INIT_RESERVE=8589934592 (the flat 8 GiB reserve #117412 introduces) and both passed. So this is rule 3c and not rule 3d, and #117411 is not a co-owner: it was closed unmerged at 11:11:48Z in favour of #117412, whose own diff comment states the causal link.

This is the only non-OK, non-SKIPPED node at this head: the praktika report is 32 OK, 137 SKIPPED and this one job's 2 ERROR nodes, and the module this PR adds a test for is not in that shard.

I have not merged master to pick #117412 up, and the reason here is ownership rather than cost: the head commit 21065bec651a of this branch was authored and committed by @ PedroTadim at 2026-09-01T07:37:42Z, merging origin/master into it. Pushing my own master merge on top would collide with work someone else is doing on the branch, so I am leaving the pickup to whoever is driving it.

Mergeable Check reports Failed: Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6) at this head, which counts only the jobs it gates on. The table above is the complete non-OK, non-SKIPPED node set of the head's praktika report, so it also covers the rows Mergeable Check does not gate.

CH Inc sync was success at this head.

Session id: cron:our-pr-ci-monitor:20260901-163000

@PedroTadim
PedroTadim added this pull request to the merge queue Sep 1, 2026
Merged via the queue into ClickHouse:master with commit fca8bfb Sep 1, 2026
173 of 175 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants