Skip to content

Add a documentation search Web UI backed by system.documentation - #108345

Merged
alexey-milovidov merged 46 commits into
masterfrom
docs-instant-search-demo
Jul 1, 2026
Merged

alexey-milovidov merged 46 commits into
masterfrom
docs-instant-search-demo

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jun 24, 2026 •

Copy link
Copy Markdown
Member

Adds /docs — "ClickHouse Reference", a small, self-contained Web UI for instant search over the new system.documentation table.

Type in the search box and it queries system.documentation over HTTP (parameterized, debounced), shows the matches in a type-color-coded list, and renders the selected entity's Markdown. Rendering includes:

  • ClickHouse SQL syntax highlighting of code blocks via the embedded Lexer.wasm (the same lexer play.html uses);
  • TeX math via KaTeX (e.g. the formula on the corr page);
  • :::note/:::tip/... admonitions, heading anchors with shareable links, and a hover "Copy" button on code blocks;
  • relative links resolved to another documented entity in-app when it exists, otherwise to https://clickhouse.com/docs; "Related" and "Alias of" references become in-app links.

State (search term, open entity, section) is mirrored into the URL fragment via the History API; there is a light/dark theme switcher with autodetection and memoization, matching play.html (logo, typefaces, theme-aware scrollbars).

The page is wired up like the other built-in UIs (/play, /merges, /schema, ...) in WebUIRequestHandler and HTTPHandlerFactory.

The renderer assets (marked, katex, and the KaTeX fonts, which are inlined into the stylesheet) are embedded in the binary and served from /js/, not from a CDN. DocsWebUIRequestHandler rewrites the CDN links in the source to the same-origin /js/ paths when serving the page, mirroring dashboard.html, so no third-party network code runs in the ClickHouse HTTP origin that handles the user's credentials, and the page stays self-contained. The /docs cross-link name cache is no longer populated from a failed or unauthenticated request, and it is invalidated when the connection (URL/user/password) changes.

While building this, I also fixed the embedded documentation so it does not produce empty code boxes:

  • FunctionDocumentation::examplesAsString / Documentation::examplesAsString no longer emit a Query/Response fenced block when that field is empty (e.g. some internal functions);
  • the filesystem and format table-function examples no longer double-wrap their already-fenced queries.

Stateless tests guard against regressions: 04408_system_documentation_no_empty_code_blocks checks for empty Query/Response fences, and 04409_docs_web_ui_local_assets checks that the served /docs page references the local /js/ assets and loads no CDN code.

Related: #89377

Changelog category (leave one):

  • New Feature

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

Added a built-in documentation search page, available at the /docs path of the HTTP interface, that provides instant search over the system.documentation table and renders the reference documentation (with syntax highlighting, math, and cross-links).

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Documented at docs/en/interfaces/documentation-search.md (slug /interfaces/documentation-search).

Add `/docs` ("ClickHouse Reference"), an embedded single-page Web UI for
instant search over `system.documentation`, rendering each entity's Markdown
(with KaTeX math, ClickHouse SQL syntax highlighting via the embedded
`Lexer.wasm`, `:::note` admonitions, heading anchors, and in-app links to
related/aliased entities). Wired up like the other built-in pages (`/play`,
`/merges`, ...) in `WebUIRequestHandler` and `HTTPHandlerFactory`.

Also fix the embedded documentation so it does not emit empty fenced code
blocks: `examplesAsString` no longer emits a `Query`/`Response` block when that
field is empty, and the `filesystem`/`format` table-function examples no longer
double-wrap their already-fenced queries. Covered by a new stateless test.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4ad7e742]

Summary: ✅


AI Review

Summary

This PR adds the built-in /docs reference/search UI backed by system.documentation, serves its renderer assets from the ClickHouse binary, wires the route into the HTTP UI handlers, and cleans up embedded documentation so it renders without accidental empty or indented code blocks. I rechecked the current code against the prior inline threads; the previously reported asset, cache, CORS/auth, sanitizer, link-routing, license, and test-coverage issues have been addressed, and I found no remaining correctness, security, or compatibility blockers.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Jun 24, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

I'm already in shock at how good it looks and feels.

A draft - because not every visual detail is polished.

Comment thread programs/server/docs.html Resolved
Comment thread programs/server/docs.html Resolved
alexey-milovidov and others added 3 commits June 24, 2026 17:17
The built-in `/docs` documentation search page loaded the `marked` (Markdown)
and `katex` (TeX math) renderers from `cdn.jsdelivr.net`. That executes
third-party network code inside the ClickHouse HTTP origin, which also handles
the `user`/`password` credentials entered on the page, so a CDN or package
compromise could read those credentials or issue and exfiltrate queries as the
user. It also broke the page's self-contained/offline contract.

Vendor `marked.min.js`, `katex.min.js`, and `katex.min.css` under
`programs/server/js/` and serve them from the binary via the existing
`JavaScriptWebUIRequestHandler` `/js/` route. The KaTeX fonts are inlined into
the stylesheet as `data:` URIs, so the page pulls no external font files either.
`DocsWebUIRequestHandler` rewrites the CDN links to the same-origin `/js/` paths
when serving the page, mirroring how `DashboardWebUIRequestHandler` handles
`uplot.js`/`lz-string.js`; the CDN URLs are kept in the source so the page still
works when opened as a local file against a remote server.

Add a stateless test `04409_docs_web_ui_local_assets` that checks the served
page references the local `/js/` assets, loads no `cdn.jsdelivr.net` code, and
that the assets are served from the binary with the fonts inlined.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`loadAllNames` on the `/docs` page caches the entity-name map even when the
request to `system.documentation` failed or returned a non-OK response. On a
server that requires credentials, the background call during initial page load
runs before the user enters them, stores an empty map, and then `rewriteLinks`
and `linkifyReferences` keep using that stale empty cache even after later
searches succeed with the new credentials, until the page is reloaded.

Publish `all_names` only after a successful response (a failed or errored
request returns an empty map for that call but leaves the cache unset so a later
call retries), and invalidate the cache when the connection URL, user, or
password changes so it is rebuilt against the new connection.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Document the new built-in `/docs` HTTP page (the documentation search Web UI
backed by `system.documentation`): what it does, how it connects, that all
renderer assets are served from the binary rather than a CDN, and the security
considerations. Mirrors the structure of the `web-terminal.md` page.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread src/Server/WebUIRequestHandler.cpp Resolved
Comment thread programs/server/docs.html Resolved
Comment thread programs/server/docs.html Resolved
alexey-milovidov and others added 8 commits June 24, 2026 17:42
In the dark theme of the `/docs` documentation search page, links used a blue
(`#4AA8FF`) that does not fit the dark palette. Use the ClickHouse yellow
(`#FF0`) — the same accent the page header already uses — instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The `/docs` page issued its queries without an `Authorization` header, so the
browser could attach stored HTTP Basic credentials and the page would
authenticate as a cached `default` login instead of the empty credentials in the
form. Send `Authorization: never` on the fetches, exactly as `play.html` does,
so that empty `user`/`password` fields connect as the default user with an empty
password rather than as a cached `default` login.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…cpp`

`WebUIRequestHandler.cpp` embeds its web UI resources with `#embed`, but the
`OBJECT_DEPENDS` list was missing several of them — `viz-standalone.js`,
`processors_profile.html`, and `docs.html` — as well as the newly added
`marked.min.js` and `katex.min.{js,css}`. Without those entries, editing one of
the missing files did not trigger a recompile, so an incremental build kept
embedding (and serving) a stale page. List every embedded resource so each one is
tracked as a dependency.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…rged 04409 test

Merging master brought in 04409_system_documentation_source_and_entities,
which collides with this PR's 04409_docs_web_ui_local_assets. Renumber the
latter to 04410.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…` page

The merged \`system.documentation\` work added more kinds of documented
entities (compression codecs, profile events, current and asynchronous
metrics, and the system tables themselves) and a \`source\` column with the
repository-relative path of the file each entity's documentation comes from.

Color-code the new entity kinds in the result list, and select \`source\`
in the search query so it is available for rendering. Next to the title of
the open entity, show a pencil link to its source file on GitHub (the
\`master\` branch); it is omitted when the source location is unknown (e.g.
an alias of an undocumented function).

Test 04411 checks that the served page selects \`source\`, points the pencil
link at GitHub, and color-codes the new entity kinds.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
When the page is opened as a local file (`file://`) and pointed at a remote
ClickHouse server, the queries are cross-origin (the browser sends
`Origin: null`), and ClickHouse only adds `Access-Control-Allow-Origin` when
`add_http_cors_header=1` is set. The previous condition suppressed the header
in exactly the `file://` case that needs it, so searches and `loadAllNames`
were blocked by CORS. Request the header unconditionally, like `/play` and
`/schema`.

Addresses review feedback.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…that produced it

The cross-link name cache (`all_names`) was published unconditionally at the
end of `loadAllNames`. If the user changed the connection (server URL, user, or
password) while the request was in flight, the `change` handler cleared
`all_names`, but the older in-flight request then resolved and re-populated the
cache with names fetched from the previous server or user. Subsequent searches
ran against the new connection while `rewriteLinks`/`linkifyReferences` used the
stale names, so in-app documentation links could point to entities that do not
exist or mean something different on the active server.

Snapshot a connection generation counter (`connection_seq`, bumped on every
connection change, mirroring the existing `request_seq` pattern used to discard
superseded keystrokes) before issuing the request, and publish into `all_names`
only when the snapshot still matches. The immediate caller still receives the
fetched map, but a stale in-flight response is no longer cached.

Addresses the AI review finding on `programs/server/docs.html`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread programs/server/docs.html Resolved
Comment thread programs/server/docs.html Resolved
alexey-milovidov and others added 2 commits June 25, 2026 23:15
…ry and connection

`runSearch` checked `request_seq` only after `fetch` returned, but then awaited
`response.text()` a second time without re-checking. A newer keystroke (bumping
`request_seq`) or a connection change (bumping `connection_seq` and clearing
`all_names`) during that second await let the stale body still replace `current`
and render against the now-current `URL`/credentials, mixing results from the
previous connection into the rebuilt cross-link cache.

Snapshot `connection_seq` at the start of `runSearch` (mirroring `loadAllNames`)
and re-check both `request_seq` and that snapshot after each `await`, so a
superseded response is dropped instead of rendered.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov
alexey-milovidov marked this pull request as ready for review June 26, 2026 19:30
alexey-milovidov and others added 2 commits June 26, 2026 22:24
The `/docs` documentation search page rendered the Markdown stored in
`system.documentation` by feeding the output of `marked.parse` straight into
`innerHTML`. `marked` is not a sanitizer: it passes raw HTML through verbatim
and keeps any URL scheme in links and images. Because this page intentionally
queries the server `URL` the user enters and renders the response in the same
HTTP origin that holds the connection credentials, an untrusted or compromised
`system.documentation` could inject `<img src=x onerror=...>` or
`[x](javascript:...)` that runs in this origin, reads the `user`/`password`
fields, and issues same-origin queries.

Sanitize every rendered document against an allowlist before it reaches the DOM:
elements not on the list are dropped with their subtree, attributes not on the
list (including all `on*` event handlers) are removed, and `href`/`src` are kept
only for safe URL schemes (`http`, `https`, `mailto`, relative, and `#`
fragments) — `javascript:`, `data:`, `vbscript:`, and the like are rejected, with
ASCII whitespace and control characters stripped first so tricks like
`java\tscript:` are still caught. The allowlist covers what Markdown, the
admonition and math extensions, and KaTeX (its HTML and the parallel MathML)
legitimately produce, so syntax highlighting, math, admonitions, and cross-links
are unaffected.

Add `04412_docs_web_ui_markdown_sanitized` to guard that the served page routes
rendered Markdown through the sanitizer, keeps the element/attribute allowlist
and the URL-scheme policy, and no longer contains the direct-`innerHTML` sink.

Addresses the review at
#108345 (review)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@dhtclk

dhtclk commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Related downstream PR here when this merges ClickHouse/clickhouse-docs#6453

@dhtclk
dhtclk self-requested a review June 26, 2026 21:24
`preprocessMarkdown` strips MDX status badges so that an unstripped
self-closing custom tag such as `<ScalePlanFeatureBadge .../>` does not
get parsed by the HTML parser as an unclosed non-void element that
swallows the rest of the document into its subtree (which the sanitizer
then drops, rendering the entry empty or truncated). It stripped the
known names in `MDX_COMPONENTS` plus any component brought in by a local
`import`. That leaves a `*Badge` the documentation toolchain adds later
and that an entry uses without a local import unhandled.

Strip any `*Badge` component by name regardless of import, removing the
dependency on the local `import` being present, the same way the terminal
Markdown renderer (`TerminalMarkdownRenderer`) already does. A `*Badge`
is a PascalCase component name that does not occur in documentation
prose, so this does not over-strip.

New test `04493_docs_web_ui_badge_strip`.

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

Copy link
Copy Markdown
Member Author

Pushed 561388a5c19..3724c5040df addressing the AI review's "Request changes" (both Major findings, both inline threads now resolved).

Relative-link routing (toDocsURL) — 561388a5c19

The two corpus links that still fell back to the bare https://clickhouse.com/docs root now resolve to their canonical route while keeping the #anchor:

  • merge-tree-settings.md/#… (e.g. materialize_skip_indexes_on_insert): toDocsURL drops the stray trailing slash before stripping the .md/.mdx extension, and merge-tree-settings is mapped in DOCS_PAGE_ROUTE → /operations/settings/merge-tree-settings. The trailing-slash fix also repairs the matching absolute links (…/skipping-index.md/#materialize-index).
  • ../dictionaries#embedded-dictionaries (regionToPopulation): dictionaries is mapped in DOCS_SECTION_ROUTE → /sql-reference/dictionaries.

I enumerated every relative cross-section link in the corpus: the remaining uncovered heads (format pages, the aggregate-function reference/* pages, the mergetree-family/* engine pages) all resolve to a documented entity and become in-app links, so they never reach toDocsURL. New test 04492_docs_web_ui_settings_page_link_route.

MDX badge stripping (preprocessMarkdown) — 3724c5040df

preprocessMarkdown now strips any *Badge component by name regardless of import, like TerminalMarkdownRenderer does. Note: the cited <ScalePlanFeatureBadge .../> in the S3Queue docs is imported in the same doc string, so the existing import-detection already stripped it (verified end-to-end against the real corpus entry — the entry was not truncated); the generic rule hardens against future importless badges. New test 04493_docs_web_ui_badge_strip.

Validated the toDocsURL/preprocessMarkdown logic and the corpus SELECTs locally; CI builds and embeds docs.html.

CH Inc sync

The sole red is the sync conflict. The private sync branch is currently several public commits behind (it mirrors 9fee4e1fe99, before the master merge / the KaTeX commit / these two), so its conflict is in the recurring settings-doc de-dent files (play.html, ServerSettings.cpp, MergeTreeSettings.cpp). I left it for the sync to re-mirror the current head first; resolving the stale intermediate state would be superseded.

@groeneai

Copy link
Copy Markdown
Collaborator

@alexey-milovidov Attribution: STID 3782-4008 is not caused by #105066. It is the pre-existing loadOutdatedDataParts terminate (already tracked in #106736); #105066 only renamed its STID by changing the BackgroundSchedulePool frames in the stack. No new issue needed.

Evidence:

  • 3782-4008 has exactly 2 occurrences, both on 2026-06-30, both after Spawn background schedule pool threads lazily #105066 merged (13:54Z): this PR's Stress test (arm_tsan) at 16:57Z, and a separate unrelated PR's Stress test (amd_tsan) at 23:03Z. 0 master hits, nothing before the merge. (The 06-26 / 06-28 hits you saw were 3782-41fc, the chronic predecessor below, not 4008.)
  • Both stacks are the deliberate std::terminate() in the catch (...) of MergeTreeData::loadOutdatedDataParts (MergeTreeData.cpp:3026, "Loading of outdated parts failed. Will terminate to avoid undefined behaviour..."). The underlying exception in both fatal.logs is Code: 733 ... (TABLE_IS_BEING_RESTARTED), thrown by lockForShare at MergeTreeData.cpp:2951 on a BgSchPool task that raced a stress SYSTEM RESTART REPLICA. No docs/HTTP frames, so it is definitionally unrelated to this PR's contents.
  • The chronic predecessor 3782-41fc (first seen 2026-03-06; 20 hits / 14 PRs / 7 master; last hit 2026-06-28, pre-merge) has the identical crash. The only differing frames are exactly the ones Spawn background schedule pool threads lazily #105066 rewrote: eager BackgroundSchedulePool.cpp:492 threadFunction / :286 ctor-spawn became lazy :616 threadFunction / :339 spawnThreadLocked()::$_0. That line/lambda shift re-hashed the stack 41fc to 4008. Clean date handoff: 41fc last hit 06-28, 4008 first hit 06-30 16:57.

So this is the same transient-exception-hits-fail-fast-terminate bug as #106736 (its example was MEMORY_LIMIT_EXCEEDED; this trigger is TABLE_IS_BEING_RESTARTED). The fix belongs there: make loadOutdatedDataParts (and the sibling loadUnexpectedDataParts) rethrow transient runtime exceptions instead of terminating. I will note the 4008/41fc rename and the new trigger on #106736.

CI reports:

@alexey-milovidov

Copy link
Copy Markdown
Member Author

The two CI reds on the current head (3724c5040df) are both unrelated AST fuzzer flakes — this PR is docs-only (the static docs.html, the /docs handler wiring, and doc-string de-denting), so it has no code path into either failing stack:

  • AST fuzzer (amd_debug) — Logical error: Block structure mismatch in A stream (STID 0993-27f0): server-side query-plan optimization (UnionStep::updateOutputHeader → checkHeaders → QueryPlanOptimizations::optimizeTreeFirstPass). This is a chronic master-wide flake: ~160 hits in the last 30 days, including on master itself (pull_request_number = 0) on 2026-06-09/12/19/20/23/24/27/30, across dozens of unrelated PRs. No docs/HTTP frames.

  • AST fuzzer (amd_tsan) — Logical error: Expected one block from input stream (STID 4569-3857): thrown by InterpreterKillQueryQuery::getSelectResult (InterpreterKillQueryQuery.cpp:453) when the fuzzer mutates a KILL QUERY … WHERE … whose inner select returns more than one block, reached via executeASTFuzzerQueries. The Expected one block from input stream message class fires only under AST fuzzer and across distinct PRs (2026-05-12 / 05-19 / 07-01), never on master-produced code paths this PR touches. No docs/HTTP frames.

Neither can be caused by a documentation-UI / doc-string change; a rerun should clear both once the in-progress run completes.

CH Inc sync: still the stale-mirror state — the sync bot's latest mirror (91af080b7d6, 2026-06-29) predates the master merge, the KaTeX license commit, and the two link/badge fixes, so its conflict is in the recurring settings-doc de-dent files. It should re-evaluate once the bot re-mirrors the current head.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Both CI reds on the current head (3724c5040df) are pre-existing, fuzzer-only flakes, unrelated to this change (a static docs.html + doc-string de-denting + WebUI-handler wiring cannot reach these code paths). Re-ran both AST fuzzer jobs.

CH Inc sync remains the private stale-mirror state described in the previous comment.

@groeneai, for attribution: the KILL QUERY Expected one block from input stream assertion (crash-site 4569-*, #104857) hit this PR as a new STID variant 4569-3857; please confirm it belongs to that issue and provide a fix in a separate PR if not already covered.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

CI triage for head 4ad7e742 (my last triage was on the superseded head 3724c5040df, so this is a fresh look).

The single red on this head is a flaky, unrelated test:

  • 04204_global_in_join_max_rows_to_transfer_103333 in Stateless tests (arm_binary, parallel) — report.
    • Error: Code: 102 ... Unexpected packet from server 127.0.0.2:9000 (expected TablesStatusResponse, got ProfileInfo) — a distributed-query client/server protocol race, not touched by this PR (which only adds the /docs Web UI + de-dents/cleans embedded doc-strings).
    • The harness's own randomized-settings diagnosis re-ran the query 158/158 passing → "not reproducible (likely a transient issue)".
    • CIDB (last 30 days) confirms it is a pre-existing, widespread flake, not caused by this PR: it fails on master (pull_request_number = 0) and across 17+ unique PRs, and across many check types — arm_binary, amd_debug, amd_llvm_coverage (old analyzer), amd_asan_ubsan (distributed plan), Fast test (arm_darwin), amd_tsan (s3 storage) — with up to 22 failures in a single day (2026-06-30).

I could not re-run the single failed job yet (the PR workflow run is still in progress, so GitHub disallows re-running an individual job); it can be re-run once the workflow completes.

@groeneai, this test (04204_global_in_join_max_rows_to_transfer_103333, UNEXPECTED_PACKET_FROM_SERVER: expected TablesStatusResponse, got ProfileInfo) is a frequent, currently-untracked flake on master and many PRs. Could you investigate and provide a fix in a separate PR? If a fix is already in progress, please link it here.

@groeneai

groeneai commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

@alexey-milovidov

1. 04204_global_in_join_max_rows_to_transfer_103333 (UNEXPECTED_PACKET_FROM_SERVER: expected TablesStatusResponse, got ProfileInfo)

A fix is already in progress: #108854 (yours, opened 2026-06-29, currently MERGEABLE), which targets exactly this signature (Connection.cpp / ConnectionEstablisher.cpp / RemoteQueryExecutor.cpp + regression test 04489_distributed_table_status_desync_recovery). Attribution confirmed on my side and matches your PR body: it is a recurrence of #93018 / #93029 (a pooled initiator->replica connection reused while still holding an undrained ProfileInfo/EndOfStream from a previously cancelled distributed query, so the TablesStatusRequest handshake reads a stale packet). Latent precondition #95466 (|| was_cancelled in RemoteQueryExecutor::finish), recent trigger #108630.

CIDB (since 2026-06-01) backs the "widespread pre-existing flake" read: 45 failures across 33 distinct PRs and 4 master runs, over 11 check types (arm_binary, amd_debug, amd_asan_ubsan distributed plan, amd_llvm_coverage old analyzer, amd_tsan s3, Fast test arm_darwin); 35/45 are the UNEXPECTED_PACKET mode, the rest ALL_CONNECTION_TRIES_FAILED. All 4 master hits are the Code 102 signature. Report on head 4ad7e742: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=108345&sha=4ad7e74212a0582882a94c23f1966cff15efa8f0&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20parallel%29

So no separate PR from me is needed. There is no dedicated open tracking issue (only the closed #93018, which #108854 already references), so I have not opened a redundant one; happy to if you want a canonical open tracker until #108854 lands.

2. KILL QUERY Expected one block from input stream (STID 4569-3857)

Confirmed: it belongs to #104857 (crash site InterpreterKillQueryQuery::getSelectResult, 4569-* family). The -3857 suffix is just this run's fuzzed query; over 120 days the family fired on master plus 4 unrelated PRs. Fix already in progress in a separate PR: #104927 (mine, OPEN) removes the single-block assertion and collects/concatenates the SELECT blocks. No further PR needed.

3. functions stress test

Superseded. On the current head 4ad7e742 the only CI red is the 04204 flake above (CIDB shows no FunctionsStress/function_prop_fuzzer failure on this sha). The functions-stress red was on the earlier head 0276475aa61 and is the reinterpret-to-Decimal scale bug already fixed by open PR #108878, as noted on 2026-06-30.

@clickhouse-gh

clickhouse-gh Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.40% 85.40% +0.00%
Functions 92.60% 92.60% +0.00%
Branches 77.60% 77.60% +0.00%

Changed lines: Changed C/C++ lines covered: 3801/3816 (99.61%) · Uncovered code

Full report · Diff report

@alexey-milovidov

Copy link
Copy Markdown
Member Author

CI triage for head 4ad7e742.

The sole red on this head is a new, unrelated flake that surfaced (job completed 12:55Z) after the last triage (08:43Z, which covered 04204_global_in_join_max_rows_to_transfer_103333 — now green after its 158/158 re-run):

  • Stress test (arm_asan_ubsan) — Logical error: Not-ready Set is passed as the second argument for function 'A (STID 0250-4e52). Exact match for the open, tracked flake Logical error: Not-ready Set is passed as the second argument for function 'A (STID: 0250-4e52) #102803 (testing/fuzz, updated today), which the CI summary already auto-links. The stack is an AST-fuzzer set-resolution error entirely inside the query pipeline (ISimpleTransform / PipelineExecutor), with no docs/HTTP frames — unreachable from a change that only adds the /docs Web UI, wires the handler, and de-dents embedded doc-strings.

I re-ran the failed job (workflow 28501843675).

@groeneai, for attribution: please confirm the Not-ready Set STID variant 0250-4e52 belongs to #102803 (it matches the issue title exactly).

@alexey-milovidov

Copy link
Copy Markdown
Member Author

@groeneai, fix the "Not ready set" problem.

@groeneai

groeneai commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

@alexey-milovidov confirmed: STID 0250-4e52 belongs to #102803, and it is unrelated to this docs-only PR.

Not a blocker for this PR.

@groeneai

groeneai commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

@alexey-milovidov On it.

Root cause (independent read, matches your #107924 diagnosis): during primary-key / skip-index analysis, FutureSetFromSubquery::buildOrderedSetInplace calls build(), which does auto plan = std::move(source) and consumes the canonical source plan. If that speculative pipeline stops without creating the set (a subquery limit with overflow_mode = 'break', or any early stop that skips CreatingSetsTransform::generate and thus Set::finishInsert), it returns null but source is already gone. The deferred DelayedCreatingSetsStep::makePlansForSets then finds source == nullptr, adds no set-building step, and FunctionIn throws Not-ready Set. Every observed reproducer is <key_col> IN/nullIn/globalIn (SELECT ... FROM <MergeTree> WHERE ...), i.e. exactly this path.

Scope: chronic and master-wide, not PR-specific. Family STID 0250-4e52 shows 25 master hits in the last 30 days (last 2026-06-30), all under Stress / AST fuzzer / serverfuzz.

#107924 addresses exactly this by making the speculative build non-destructive. The open point is the clone-vs-flag design question in the review. My plan: deterministically reproduce it (via your prepared_sets_build_ordered_set_inplace_fail failpoint), confirm #107924 resolves all observed shapes, and audit the sibling buildSetInplace path (still destructive on master, not covered by #107924) for the same defect. If you would rather I implement vdimir's flag-based alternative as a separate PR for comparison, say the word.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 1, 2026
Merged via the queue into master with commit a520827 Jul 1, 2026
511 of 514 checks passed
@alexey-milovidov
alexey-milovidov deleted the docs-instant-search-demo branch July 1, 2026 21:56
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 1, 2026
dhtclk added a commit to fastio/clickhouse-docs that referenced this pull request Jul 7, 2026
Adds the `interfaces/documentation-search` page (the /docs search Web UI)
to the "Native clients & interfaces" sidebar group so it is not a
floating page once it syncs from the ClickHouse repo.

Depends on ClickHouse/ClickHouse#108345, which adds the page source. Must
not be merged until that PR is in ClickHouse master, otherwise the docs
build fails on a sidebar entry pointing at a non-existent doc.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
dhtclk added a commit to fastio/clickhouse-docs that referenced this pull request Jul 7, 2026
Step 1 of adding the /docs Web UI page (ClickHouse/ClickHouse#108345):
excepts the new interfaces/documentation-search page from the
floating-pages check so the docs check on #108345 passes. Once #108345
merges, a follow-up PR removes this entry and adds the page to
sidebars.js.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
The `/docs` documentation search page rendered the Markdown stored in
`system.documentation` by feeding the output of `marked.parse` straight into
`innerHTML`. `marked` is not a sanitizer: it passes raw HTML through verbatim
and keeps any URL scheme in links and images. Because this page intentionally
queries the server `URL` the user enters and renders the response in the same
HTTP origin that holds the connection credentials, an untrusted or compromised
`system.documentation` could inject `<img src=x onerror=...>` or
`[x](javascript:...)` that runs in this origin, reads the `user`/`password`
fields, and issues same-origin queries.

Sanitize every rendered document against an allowlist before it reaches the DOM:
elements not on the list are dropped with their subtree, attributes not on the
list (including all `on*` event handlers) are removed, and `href`/`src` are kept
only for safe URL schemes (`http`, `https`, `mailto`, relative, and `#`
fragments) — `javascript:`, `data:`, `vbscript:`, and the like are rejected, with
ASCII whitespace and control characters stripped first so tricks like
`java\tscript:` are still caught. The allowlist covers what Markdown, the
admonition and math extensions, and KaTeX (its HTML and the parallel MathML)
legitimately produce, so syntax highlighting, math, admonitions, and cross-links
are unaffected.

Add `04412_docs_web_ui_markdown_sanitized` to guard that the served page routes
rendered Markdown through the sanitizer, keeps the element/attribute allowlist
and the URL-scheme policy, and no longer contains the direct-`innerHTML` sink.

Addresses the review at
ClickHouse#108345 (review)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
Some embedded documentation entries open with an MDX status badge that the text
does not `import` locally: `transactionID`, `transactionLatestSnapshot`, and
`transactionOldestSnapshot` start with a bare `<ExperimentalBadge/>` /
`<CloudNotSupportedBadge/>`. `preprocessMarkdown` only stripped the components
that were actually imported, so these survived. The HTML parser then treats the
self-closing custom tag as an unclosed non-void element that swallows the rest of
the document, and the sanitizer drops that whole subtree, so the entry renders as
an empty page.

Seed the strip set with a curated allowlist of known MDX components
(`MDX_COMPONENTS`) so they are removed whether or not they were imported, while
still preserving literal `<...>` placeholders in prose (e.g. a `<SearchPhrase>` in
an XML example).

Adds `04418_docs_web_ui_importless_mdx_badge` and updates
`04415_docs_web_ui_mdx_components_stripped` for the changed initialization.

Addresses review on ClickHouse#108345

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…down sanitizer

The `/docs` page renders Markdown from `system.documentation` through an allowlist
sanitizer that drops elements not on the list together with their whole subtree.
Some embedded docs wrap a note in an ordinary `<details><summary>...</summary>...</details>`
disclosure block, for example the "Implementation details" sections of the `uniq`
and `uniqCombined` aggregate functions. Because `details` and `summary` were not on
the allowlist, those sections were removed from the rendered page entirely.

Add `details` and `summary` to the tag allowlist and `open` to the attribute
allowlist; these are safe, standard HTML5 disclosure elements.

Adds `04417_docs_web_ui_disclosure_details`.

Addresses review on ClickHouse#108345

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…d relative cross-section paths

Two gaps in the `/docs` renderer's link handling, both losing or misrouting real
existing documentation:

- `rewriteLinks` collapsed every entity type to one lower-cased `name`, but names
  are not unique across types in `system.documentation` (for example `JSON` is both
  a data type and a format). A link such as `[JSON](/interfaces/formats/JSON)` was
  rewritten to the `JSON` data type instead of the `JSON` format. Keep all
  same-named entities (`all_names` now maps a name to the list that share it) and
  disambiguate by the link's target route (`typeFromDocsHref` / `resolveDocEntity`);
  when the route gives no hint, leave the link as an external docs link rather than
  guessing. `linkifyCode` (for `Related:`/`Alias of` references, which carry no
  route) linkifies only an unambiguous single match.

- `toDocsURL` resolved every relative fallback as if it were rooted at `/docs` by
  stripping the leading `../`, so a source-relative cross-section link such as
  `mortonEncode`'s `../data-types/int-uint.md` became the broken
  `/docs/data-types/int-uint` instead of `/docs/sql-reference/data-types/int-uint`.
  Resolve the first segment of a relative path to its canonical section route
  (`DOCS_SECTION_ROUTE` / `DOCS_ROUTE_ROOTS`).

Adds `04419_docs_web_ui_link_disambiguation` and
`04420_docs_web_ui_relative_link_route`.

Addresses review on ClickHouse#108345

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…d of a fabricated path

Addresses the review on PR ClickHouse#108345: `toDocsURL` resolved the leading segment of
an unmappable relative link from the docs root, so a bare same-directory link such
as `textindexes.md` became `https://clickhouse.com/docs/textindexes`, which 404s
(the real route is `/engines/table-engines/mergetree-family/textindexes`). Such a
link carries no section information, and an entity's embedded `source` is a code
path, not a docs path, so its docs route cannot be determined.

`toDocsURL` now falls back to the docs root for any relative link whose route it
cannot map, matching the function's own stated intent ("fall back to the docs root")
and the fail-close principle of not emitting a fabricated path. The few embedded
documentation entries that used bare same-directory links now spell them as absolute
docs routes that resolve correctly in both the `/docs` page and the website:
`textindexes`/`annindexes` in the `MergeTree` table-engine docs and
`memory-overcommit` in the memory-limit settings.

New test `04489_docs_web_ui_same_directory_link` covers the same-directory case.
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…rch-demo

Add a documentation search Web UI backed by system.documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature Pull request with new product feature 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.

5 participants