Skip to content

Web UI: store credentials for the implicit default user - #118637

Open
alexey-milovidov wants to merge 64 commits into
masterfrom
play-store-credentials-default-user
Open

alexey-milovidov wants to merge 64 commits into
masterfrom
play-store-credentials-default-user

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

The Web UI (play.html) offers the login to the browser's password manager via navigator.credentials.store after each Run. It passed the raw user field as the PasswordCredential id. When the field is empty (the server's default_session_user), the constructor throws TypeError: Failed to construct 'PasswordCredential': 'id' must not be empty. on every Run, so such logins were never saved. Firefox has no PasswordCredential at all, which raised a ReferenceError there on every Run.

Now the call is skipped in browsers without the API, and with an empty user field the login is stored under the real name of the implicit user: the server is asked for currentUser (in getServerStatus, with no user parameter, so the page never assumes default). When the password manager refills that name on the next visit, it selects the same account explicitly. Nothing is stored if the server cannot tell. The probe is sent only after the Run has settled, so it does not compete with the Run's query for the user's query slots (max_concurrent_queries_for_user), and without session_id / session_check / session_timeout, so it does not contend for the HTTP session lock (SESSION_IS_LOCKED) with a query of another tab. A passwordless login of an empty user field is also recorded under the account's name, so a stale autofilled password of the refilled login is dropped (dropAutofilledStalePassword). A server URL with a userinfo (http://alice@host:8123/) cannot be used from the page, because fetch refuses URLs with credentials, so no login is stored for it.

Tested by the new test_play_credentials_store integration test: a Node harness (like test_play_reconcile_startup) runs the real functions extracted from the served page against a fake PasswordCredential and a fetch stub that, like the browser, rejects credentialed URLs. It covers the implicit default and a non-default default_session_user round trip, an explicit user, a probe outside of the session and after the Run, a refill after a passwordless login, and the cases where nothing is stored.

Related: #118638

Changelog category (leave one):

  • Improvement

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

Web UI: when the user field is empty, the browser's password manager is now offered the login under the name of the user the server authenticates, instead of the page failing with an exception.

🤖 Generated with Claude Code


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

`storeCredentials` in `play.html` passed the raw `user` field as the
`PasswordCredential` id. An empty field (the server's `default` user, or
a user embedded in the server URL's userinfo) made the constructor throw
`TypeError: 'id' must not be empty` on every Run, so such logins were
never offered to the browser's password manager. Use the effective user
(`effectiveConnectionUser`, falling back to `default`) instead, and skip
the call in browsers without `PasswordCredential` (Firefox).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e21aef7]

Summary: ❌

job_name test_name status info comment
Finish Workflow FAIL
python3 ./ci/jobs/scripts/workflow_hooks/can_be_merged.py --review-threads FAIL

AI Review

Summary

The change saves implicit Web UI logins under the server-reported account, guards unsupported credential APIs, and carries account stamps through results, history, shaping, and Download. Reviewed PR head e21aef7d220bfa1ea6cd775ca5dfc85e03a6dcb7. The three JavaScript harnesses pass (31 credential scenarios, 142 startup checks, 103 shaping checks), and the current Praktika report reports no failed tests. One new export correctness blocker remains, along with the explicitly deferred stamp issue below.

Findings

❌ Blockers

  • programs/server/play.html:17007: A mismatched implicit account is not safely pinned by adding user=. Configured HTTP handlers with handler.user authenticate using AlwaysAllowCredentials and ignore URL credentials. After restoring an alice result on a new visit to a handler now configured as bob, the probe reports bob, but Download submits user=alice and succeeds as bob. The mismatch branch at line 17047 has the same defect. A reproduction through the production Download handler and a transport model matching authenticateUserByHTTP submitted one form as bob, with user=alice and no alert. Refuse mismatched exports, or verify that the final explicit-username request authenticates as the recorded account.

  • programs/server/play.html:16897: A same-visit account change can stamp a new run with an earlier account. [dismissed by author -- https://github.com/Web UI: store credentials for the implicit default user #118637#discussion_r4247575425] The author explicitly deferred changes during a page visit; this remains real because implicitUserStamp reuses the last learned name without validating the launching request. Rechecking the current helpers reproduced an implicit request authenticated as bob, a snapshot stamped alice, and Download selecting alice. Scope proof to a validated launch/connection generation, or explicitly track this accepted limitation in a follow-up issue. No thread was reopened or replied to.

Tests
  • ⚠️ Add a focused restored-result case where a configured dynamic_query_handler authenticates as bob despite user=alice; Download must refuse to export the wrong account's result. Existing proxy and Basic-auth models do not cover configured credentials.
Final Verdict

Status: ❌ Block

Prevent the configured-handler export mismatch and cover it with a regression case. Fix or link a tracking issue for the deliberately deferred same-visit account-stamp limitation.

Comment thread programs/server/play.html Resolved
@clickhouse-gh clickhouse-gh Bot added the comp-protocols Server wire protocols + request/response handling (native TCP, HTTP, MySQL/PostgreSQL wire protoc... label Sep 7, 2026
alexey-milovidov and others added 2 commits September 16, 2026 11:37
Address review: saving the implicit login under `default` (or under the user embedded in the
server URL's userinfo) was not safe on its own, because `postImpl` and the other request
builders appended `&user=` for any non-empty `user` field. Once the password manager refilled
the remembered name into the field, the request stopped being the implicit-auth request it was
saved from and was forced to `user=default`, which can override the URL userinfo.

Now every request URL of the page obtains its `user` parameter from the new `userUrlParam`,
which omits the parameter when the field equals the user an empty field already authenticates
as (`effectiveConnectionUser` with an empty field: `default` on a plain server URL, or the
userinfo user). So a refilled remembered login builds exactly the request an empty field
builds, and a field naming a different user still takes precedence as before.
`effectiveConnectionUser` now returns `default` instead of an empty string when neither a field
user nor a userinfo is given, so the history / database-panel identity gates treat a typed or
autofilled `default` as the same connection as an empty field, and `storeCredentials` stores
that never-empty name directly.

Adds `test_play_credentials_store`, a Node harness (like `test_play_reconcile_startup`) that
runs the real `storeCredentials`, `effectiveConnectionUser`, `userUrlParam`, `getServerStatus`
and `buildCompletionUrl` extracted from the served page: it stores the login with an empty
field, simulates the password manager refilling it, and requires the request URLs and the
connection identity to be unchanged, for the implicit `default`, a URL userinfo, a
percent-encoded userinfo, and an explicit `default` overriding a userinfo. A source-level
scenario pins that no request builder appends `&user=` bypassing `userUrlParam`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Comment thread programs/server/play.html Resolved
alexey-milovidov and others added 4 commits September 19, 2026 18:01
…default`

Address review: `authenticateUserByHTTP` substitutes `default_session_user`
for an empty `user`, which is server configuration and not necessarily
`default`. Hard-coding `default` made `storeCredentials` remember the wrong
name and `userUrlParam` drop an explicit `default` as redundant, so the page
could keep authenticating as another user while showing and storing `default`.

Now `effectiveConnectionUser` keeps the fully implicit case empty (only the
URL userinfo user is derivable locally), `userUrlParam` omits the `user`
parameter only for the userinfo user, and `storeCredentials` asks the server
for `currentUser` (via `getServerStatus`, sent without a `user` parameter)
and saves the login under the reported name, storing nothing if the server
cannot tell. The harness covers a non-`default` session user and an explicit
`default` without userinfo.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118637&sha=afd5a1aab0eee388ce3fcf8ffabbb5d762194818&name_0=PR&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%201%2F8%29 (test_max_bytes_ratio_before_external_order_group_by_for_server/test.py::test_max_bytes_ratio_before_external_distinct[user]) and provide a fix in a separate PR. If the fix is already in progress, link it here. This PR only changes programs/server/play.html and its Node harness, so it cannot cause this failure. The same applies to the Performance Comparison (arm_release, master_head, 1/6) regressions in array_first_last and optimize_time_filter_with_preimage.

Comment thread programs/server/play.html Resolved
Comment thread programs/server/play.html Resolved
@groeneai

Copy link
Copy Markdown
Collaborator

Investigated all three.

  1. test_max_bytes_ratio_before_external_distinct[user]: the ratio 0.3 spilling query at test.py:134 runs into the harness's fixed 600 s per-query client cap (DEFAULT_QUERY_TIMEOUT in tests/integration/helpers/client.py), not into a memory limit. On amd_asan_ubsan, db disk the whole test takes 586 s at p50, and since Skip the RSS-based half of the external DISTINCT memory test under ASan #121454 merged the [user] arm failed 10 of 1941 runs, all at 607 to 611 s, on 9 PRs and once on master: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=8a7ac3150a813ffadd593f0c19e2a85a77108224&name_0=MasterCI&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%201%2F8%29
    This is the original workload: Trim test_max_bytes_ratio_before_external_distinct to fit the client timeout #121096 had cut it, and Revert "Trim test_max_bytes_ratio_before_external_distinct to fit the client timeout" #121477 reverted that because of the [server] arm, which Skip the RSS-based half of the external DISTINCT memory test under ASan #121454 now skips under ASan. No open PR covers [user]; I will send one and link it here.

  2. array_first_last #9 (56.1 to 68.3 ms) is the same query as on Parallelize merging of large uniqExact states in aggregation with keys #117153. That fix is in progress, and I will link the PR here too.

  3. optimize_time_filter_with_preimage #4 (549 to 664 ms) is the DateTime month baseline arm, one of the three optimize_time_filter_with_preimage = 0 arms that my open Remove the disabled-optimization baseline arms from the preimage performance test #122156 removes.

@clickhouse-gh

clickhouse-gh Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing e21aef7d2 with master 19f5e0ac8 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

4 object files changed (+42.13 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Server/WebUIRequestHandler.cpp.o 12.39 MiB 12.43 MiB +42.14 KiB (+0.33%)

716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

6 translation units recompiled, 3 s compile time in total, 6 of them have a recent master baseline.

Job report

@groeneai

Copy link
Copy Markdown
Collaborator

Both fixes are open now:

  1. test_max_bytes_ratio_before_external_distinct[user]: Run the user-limit case of the external DISTINCT ratio test at 4 GiB to fit the ASan query timeout #122494 runs this case with 7M keys against a 4 GiB user limit instead of 100M keys against 10 GiB, so on my ASan build its spilling query takes 44 s instead of 412 s.
  2. array_first_last #9: Stabilize the two arrayLast filter queries of the array_first_last performance test #122483.

alexey-milovidov and others added 2 commits October 3, 2026 07:57
…ion, drop the URL userinfo contract

`storeCredentials` asks the server for `currentUser` while the query of the
Run may still be in flight. With a `session_id` in the connection URL the two
requests contended for the same session, and the server rejects a concurrent
request with `SESSION_IS_LOCKED`, so the user's query could fail. The probe now
goes to the server URL without `session_id`, `session_check` and
`session_timeout` (`serverAddressWithoutSession`); the other parameters are kept
byte for byte.

`fetch` refuses URLs with credentials, so a server URL with a userinfo
(`http://alice@host:8123/`) cannot be used from the page at all. Treating the
userinfo as an implicit-auth source in `userUrlParam` encoded an unsupported
contract, so `userUrlParam` is removed and the request builders are back to
sending the `user` field as before. No login is stored for such a URL. The
harness's `fetch` stub now rejects credentialed URLs like the browser does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread programs/server/play.html Resolved
alexey-milovidov and others added 2 commits October 5, 2026 01:39
…implicit one

`storeCredentials` remembers an implicit login under the server-reported
`currentUser`, but the connection-identity gates (`resetConnectionScopedState`,
`liveDivergedFromRun`, the `window.onpopstate` restore) still treated the empty
`user` field and the refilled name as different connections, so an autofilled
login could clear `selected_database` and mark a `run=1` entry as diverged.

Remember the learned implicit user per server endpoint in `localStorage` (the
refill happens on the next visit) and fold it into `effectiveConnectionUser`.
The Back/Forward restore now compares the user by identity too, so it does not
replace a refilled login and drop its password.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failures of 04653_bloom_filter_fixed_string_constant_scalar, 04819_dynamic_aggregate_function_state_version and 05237_with_expression_alias_scope_descendant in Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) / Stateless tests (arm_binary, s3 storage, DBReplicated, parallel, 1/2): https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118637&sha=1b3d98382e7502013b8fde2a5e07df34e59d2002&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29 and provide a fix in a separate PR. If the fix is already in progress, link it here. (This PR only changes programs/server/play.html. 03008_optimize_equal_ranges and 05257_sql_security_view_sealed have open fixes in #123695 and #123729; the TimeSeries tests were fixed on master, which is now merged.)

Comment thread programs/server/play.html Resolved
@groeneai

groeneai commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

All three have fixes in progress:

The identity of a stored connection with an empty user (a result snapshot,
a history entry, the selected database) was re-derived from the current
`implicit_users` cache in `localStorage`, so after the server's
`default_session_user` changed, an old implicit entry could be reinterpreted
as belonging to the newly learned name and keep its `database=` / `run=1`.

Record the learned implicit user next to every stored connection when it is
recorded (`implicitUserStamp`: `implicitUser` on result snapshots and
connection snapshots, `connectionImplicitUser` on history entries), and
compare stored connections with the live one through `sameConnectionUser`,
which uses the stored stamp. An entry without a stamp matches only an
implicit live user (fail closed). `effectiveConnectionUser` no longer
consults the cache.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118637&sha=0692bc494e5fb12d09a36331ee78b3068926594b&name_0=PR&name_1=Stress%20test%20%28amd_debug%29 (Logical error: 'Cannot write to canceled buffer' from ClientEmbeddedRunner::clientRoutine -> ClientBase::processQueryText). It is unrelated to this PR, which only changes play.html and its harnesses. It looks like #125973, with a fix in progress in #126142. If that PR does not cover this path, please provide a fix in a separate PR.

@groeneai

Copy link
Copy Markdown
Collaborator

The stack at 0692bc4 (from clickhouse-server.err.log, query INSERT INTO t_nb VALUES, STID 4158-2bb4) is WriteBuffer::write <- ProgressIndication::writeProgress <- ClientBase::onProfileEvents <- receiveEndOfQueryForInsert <- processInsertQuery <- processQueryText <- runInteractive <- ClientEmbedded::run.

That is the site fixed by #127834: its isCanceled() early return at the top of writeProgress covers both the onProgress and the onProfileEvents callers. The build (git hash 022001d) is the merge of 0692bc4 into master bee6dea (2026-10-30 01:27Z), 15 commits before #127834 landed (553f228, 08:05Z), so the fix was not in this run. CIDB shows no hit of this site on a build that contains #127834 so far.

#126142 covers the other embedded-client site, resetOutput -> IOutputFormat::finalize. That one still fires on builds that contain #127834 (Stress test (amd_msan), build e0922ea), so #126142 is still needed, but it is not this path. No separate PR is needed for this failure.

… probe in flight

`learnImplicitUser` keyed its in-flight probes by `required` too, so the
verification of `replayConnectionUser` sent a second identical probe while an
optional one was in flight. With `max_concurrent_queries_for_user = 1` the
server rejected it with `TOO_MANY_SIMULTANEOUS_QUERIES`, the verification failed
and the Download named the account, which a proxy-authenticated server rejects.

Required and optional callers now share the probe in flight. If the shared
optional probe was skipped after an export, the required caller sends its own
once the skipped one has settled. New harness scenario
`proxy-authenticated-replay-joins-optional-probe`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread programs/server/play.html Resolved
`checkCredentials` called `getServerStatus` directly, so with
`max_concurrent_queries_for_user = 1` a check sent while an implicit-user
probe was in flight was rejected with `TOO_MANY_SIMULTANEOUS_QUERIES`, and
valid credentials were shown as failed with the connection menu opened.
Admit it through `admitRunQuery`, and add the `credentials-check-waits-for-probe`
regression scenario.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread programs/server/play.html Resolved
alexey-milovidov and others added 3 commits November 3, 2026 05:08
`loadCompletions` sent the completion query directly with `fetch`, so with
`max_concurrent_queries_for_user = 1` a load started while an implicit-user
probe was in flight was rejected with `TOO_MANY_SIMULTANEOUS_QUERIES`, and
the suggestions stayed unavailable until another focus retried it. Admit it
through `admitRunQuery`, holding the admission until the response body is
read, and add the `completions-wait-for-probe` regression scenario.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… during the account probe

A switch between already materialized notebook cells while `learnImplicitUser` is pending keeps
the tab, the query text and `tab.reqNum`, and with matching completed results it leaves
`deferred_run_cancelled` false, so the deferred `run=1` auto-run executed with the other cell's
parameter bindings. `runDeferredStartupQuery` now also requires an unchanged `activation_num` and
active cell after the probe. The `run-link-delayed-probe` scenario covers the cell switch; it fails
against the previous version.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread programs/server/play.html Resolved
alexey-milovidov and others added 2 commits November 15, 2026 09:54
…t a cached Basic login

The Download of an implicit result with no password is a form submission, which cannot
suppress the HTTP Basic credentials the browser may have cached for the origin, while the
verification (`replayConnectionUser`) sends `Authorization: never`. With neither `user` nor
`password` the server took the cached header, so the export could run as another account
than the verified one.

The export now carries an explicit empty `password` parameter, which the server prefers
over the `Authorization` header, after verifying exactly that request
(`implicitReplayAuthentication`). If the server authenticates it as another account, the
recorded account is named; if the server rejects the parameters as mixed with a proxy or a
certificate authentication (where a cached header is rejected too), the empty field is kept;
any other failure refuses the export.

Also add the Popover API to the fake DOM of `reconcile_harness.js`: `play.html` now closes
the download menu with `hidePopover` after the master merge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread programs/server/play.html Resolved
alexey-milovidov and others added 2 commits November 18, 2026 19:04
The verification of a passwordless Download (`implicitReplayAuthentication`)
is a different probe request than the ones `learnImplicitUser` coalesces, and
`admitImplicitUserProbe` only waited for runs, so with
`max_concurrent_queries_for_user = 1` it could lose the slot to a probe in
flight, get `TOO_MANY_SIMULTANEOUS_QUERIES`, and refuse the export. Probes now
wait for the probe in flight as well. The new harness scenario
`passwordless-download-waits-for-probe` runs the complete Download sequence
against a one-slot transport.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118637&sha=d813cbe368af46261214742cb2b1f26b487a60d0&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29 (Logical error: Context has expired (STID: 1805-3f9b), plus the follow-up Cannot list the mutations left unfinished by the stress phase and related errors) and provide a fix in a separate PR. If the fix is already in progress, link it here. This PR only changes programs/server/play.html and its JS harnesses, so it cannot affect the server. The two Performance Comparison (arm_release) failures carry the disk-almost-full label, which points to the CI runner.

@groeneai

Copy link
Copy Markdown
Collaborator

This PR did not cause the Upgrade check (amd_release) failure on d813cbe. The server that aborted is the previous release that the job runs the stress phase on, 26.10.4.207 (official build), not this PR's binary. It hit Context has expired in kqlMultiply (FunctionKQLMultiply::executeImpl -> getContext(), FunctionKQLMultiply.cpp:83) on the 02366_kql_extend query Ledger | extend PriceInCents = 100 * Price | sort by ... | summarize ... (fatal.log). The other rows (Cannot list/count the mutations left unfinished by the stress phase, Cannot list the row policies ..., Cannot submit the mutation ..., Cannot run the mutation entries ...) come from the checks that run after the stress phase: they fail with Code: 210 ... Connection refused because that server is already dead.

The fix is already merged: #131363 on master, backported to 26.10 by #132081 and first released in v26.10.6.18-stable (2026-11-18 12:47 UTC). Upgrade check runs started after that use v26.10.6.18-stable as the previous release. This signature showed up in 30 of 1367 runs before the release and in 0 of 146 runs since. The run on d813cbe started on 2026-11-15, so it still ran 26.10.4.207. The new head c475e36 will run against 26.10.6.18.

@clickhouse-gh clickhouse-gh Bot added comp-web-ui Web UI embedded in the server: Play, the dashboards, the merges and processors visualisers, the w... and removed comp-protocols Server wire protocols + request/response handling (native TCP, HTTP, MySQL/PostgreSQL wire protoc... labels Nov 19, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged the latest master (clean merge, no changes to the files of this PR; the three Node harnesses pass on the merged tree: 31 credential scenarios, the startup and the result-shaping harnesses). The Praktika report of c475e36 had no failed tests; the only red check was CH Inc sync (tests failed), caused by one test of a private-only feature that this PR cannot affect — reported in the sync PR, and the sync runs again on the new head. The Upgrade check failure discussed above is fixed by #131363, as explained by @groeneai.

clickhouse-gh[bot]
clickhouse-gh Bot previously approved these changes Nov 22, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118637&sha=84f7135e474cfd8e4b3d224527d0ecf38e40c283&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%20distributed%20plan%2C%20targeted%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.

02932_refreshable_materialized_views_2 printed <29: randomize> 1 0 instead of 1 1: next_refresh_time of rmv_g was exactly the unrandomized timeslot 2050-02-10 04:00:00. With RANDOMIZE FOR 4 DAY 1 HOUR an offset below one second has a probability of about 3e-6 (drawRandomness / RefreshSchedule::addRandomSpread), so it looks like a path in RefreshTask where the spread is not applied rather than bad luck. I found no open issue for this step, and the earlier failures of this test in the last 30 days were on other steps. This PR changes only programs/server/play.html and the Node harnesses of the Web UI, so it cannot be the cause.

Merged the latest master (clean merge; it touches none of the files of this PR) to restart the CI.

Comment thread programs/server/play.html
const account = resolvedImplicitUser(server_address, implicit_user);
if (!account) return '';
if (!learnedImplicitUser(server_address)) await learnImplicitUser(server_address, password, /* required = */ true);
return account === learnedImplicitUser(server_address) ? '' : account;

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.

[Blocker] Verify the requested account before exporting after an identity mismatch.

For a configured dynamic_query_handler with handler.user, adding user=<recorded account> does not select that account: authenticateUserByHTTP uses the configured AlwaysAllowCredentials and ignores the URL credentials (src/Server/HTTP/authenticateUserByHTTP.cpp:291-308). Restore a result stamped alice on a new visit after that handler has been changed to bob: the probe correctly reports bob, but this branch returns alice, and Download submits user=alice without verifying it. The export succeeds as bob despite being attached to the stored alice result. This does not require reconfiguration during the page visit. The mismatch branch in implicitReplayAuthentication makes the same assumption.

I reproduced the full Download handler submitting that form without an alert using the configured-user authentication behavior from the server code. Please refuse the export when the account differs, or verify that the exact request with the explicit username authenticates as the recorded account before submitting it. Cover configured handler credentials in the regression harness; its current transport assumes that a URL username always chooses the authenticated account.

@clickhouse-gh
clickhouse-gh Bot dismissed their stale review November 23, 2026 00:54

AI review of a later commit does not approve the PR, see the AI Review comment.

@groeneai

Copy link
Copy Markdown
Collaborator

Acknowledged. I'm investigating why <29: randomize> in 02932_refreshable_materialized_views_2 saw the unrandomized timeslot for rmv_g; I'll follow up here with a PR (or my findings) shortly.

@groeneai

Copy link
Copy Markdown
Collaborator

The fix is in #133657 (test-only).

I found no path that skips the spread: every finite next refresh time goes through RefreshSchedule::addRandomSpread. But system.view_refreshes.next_refresh_time is a DateTime, so a drawn offset in [0, 1 s) prints as the timeslot, about 2.87e-6 per run with RANDOMIZE FOR 4 DAY 1 HOUR. CIDB has 3 such failures of this step since 2024-07 in about 1.04M runs, against about 3.5 expected. The PR adds a second identical view to step 29: a missing spread still fails the check, a false failure now needs both draws in that range.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-web-ui Web UI embedded in the server: Play, the dashboards, the merges and processors visualisers, the w... pr-improvement Pull request with some product improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants