Repository navigation
Reject shorthand setting changes carrying a value for the whole query tree - #113192
alexey-milovidov wants to merge 19 commits into
Conversation
… tree The valueless `SETTINGS name` form stands for `name = true` and the SQL parser always writes Bool `true` for it, so `shorthand` paired with any other value can only arrive from the AST JSON dialect. `BaseSettings::checkShorthandChange` rejects it for settings applied through `BaseSettings`, but `SettingsChanges` are also consumed raw - the `Join` engine, `EXPLAIN` settings, dictionary and data-lake settings - and such a reader would execute the carried value for a change that claims to be valueless. Reject the shape once for the whole tree in `executeQueryImpl`, after `query_for_logging` is prepared, so the exception is logged with the AST masked rather than with the raw JSON text. Follow-up to #113025, addressing the remaining review finding there. Co-Authored-By: Claude Fable 5 <[email protected]>
…ng-shared-validation
Address review: \`ASTDictionarySettings::readJSON\` and \`ASTCreateWasmFunctionQuery::readJSON\` dropped the \`shorthand\` flag, so the tree-wide check in \`executeQueryImpl\` could not see it, while their consumers read the \`SettingsChanges\` raw. Restore the flag on both (and write it back on serialization), and extend \`checkValuelessSettingChanges\` to these two carriers, which store \`SettingsChanges\` directly instead of inside an \`ASTSetQuery\`.
|
🕵 The stress-test failures on 025e5f4 are unrelated to this change:
Merged |
…ng-shared-validation
… WASM function settings The dictionary and WASM function settings grammar mandates `name = value`, so the valueless form is parser-impossible there whatever the value, and it cannot be let through even with the mandatory `true`: `ASTCreateWasmFunctionQuery::formatImpl` renders its settings via a temporary `ASTSetQuery`, which elides `= true` for the valueless form, so a surviving flag would be persisted as `SETTINGS name` that `ParserCreateFunctionQuery` then fails to parse back when the function is reloaded, making the function disappear after a server restart.
…ng-shared-validation
…N settings Column-level SETTINGS (...) and EXPLAIN settings ride in an ASTSetQuery, but their grammar disables the valueless form (ParserSetQuery with shorthand_syntax = false), so the flag is parser-impossible there even with the mandatory true - and the node cannot tell in which grammar it was parsed, so the context is judged from the parent (ASTColumnDeclaration, ASTExplainQuery) in the tree walk. Nothing in these paths consults the flag: MergeTreeColumnSettings::validate only type-checks the value, so a surviving flag would be persisted in the table definition as SETTINGS (min_compress_block_size) that the column grammar then fails to parse back.
Under `--allow_merge_tree_settings` with changed MergeTree settings (the test harness randomization), `ClientBase::addMergeTreeSettings` rewrites a parsed `CREATE ... MergeTree` query and re-sends it as SQL text. The crafted shorthand column setting is then re-rendered in the valueless form `SETTINGS (min_compress_block_size)`, which the column grammar rejects with a syntax error before the server-side tree check can see the flag, so the expected `BAD_ARGUMENTS` line was missing. Send the payload over HTTP so it reaches the server verbatim. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=113192&sha=87de7ec74901db38eca6acfaee3122b492b65672&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20flaky%20check%29 #113192
…romJSON entry point `checkValuelessSettingChanges` only ran on the server `executeQueryImpl` path, so other `IAST::createFromJSON` consumers still accepted the malformed shape: `formatQueryFromJSON` could render it as SQL the grammar cannot parse back (e.g. `SETTINGS webassembly_udf_enable_fuel` for a WASM function), and the client's AST-to-SQL rewrites (query-parameter substitution for old servers, `allow_merge_tree_settings`) could serialize a crafted raw-reader payload such as `Join(... SETTINGS persistent = false)` into executable SQL, bypassing the server-side check. Move the check into `src/Interpreters/checkValuelessSettingChanges.h` and call it from `formatQueryFromJSON` and from the client's JSON-dialect parse (before any rewrite). The server keeps checking after `query_for_logging` is prepared, and `ASTSetQuery::formatImpl` stays honest for that masked-logging path. `LocalConnection`'s own `createFromJSON` needs no check: its AST is only used to detect the input format of an INSERT during execution, after the server-side check has already accepted the query text. Tests 04691 and 04665 pinned the previous behavior where `formatQueryFromJSON` formatted the malformed payload; they now expect the rejection. Test 04699 sends the crafted payloads over HTTP to keep exercising the server-side check and covers the client-side parse rejection and `formatQueryFromJSON` separately. #113192
…ng-shared-validation
Build profile diff (arm_release)Comparing Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Object file sizes
|
| Object file | Master | PR | Δ |
|---|---|---|---|
src/Storages/System/CMakeFiles/clickhouse_storages_system.dir/StorageSystemHandlers.cpp.o |
new | 257.14 KiB | +257.14 KiB |
src/CMakeFiles/dbms.dir/Common/SQLDefinedHandlers/SQLDefinedHandlersMetadataStorage.cpp.o |
new | 177.03 KiB | +177.03 KiB |
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/currentRequestURL.cpp.o |
new | 162.55 KiB | +162.55 KiB |
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/currentHandler.cpp.o |
new | 162.25 KiB | +162.25 KiB |
src/CMakeFiles/dbms.dir/Common/SQLDefinedHandlers/SQLDefinedHandlerFromAST.cpp.o |
new | 136.72 KiB | +136.72 KiB |
src/CMakeFiles/dbms.dir/Common/SQLDefinedHandlers/SQLDefinedHandlersFactory.cpp.o |
new | 125.15 KiB | +125.15 KiB |
src/Parsers/CMakeFiles/clickhouse_parsers.dir/ASTCreateHandlerQuery.cpp.o |
new | 68.53 KiB | +68.53 KiB |
src/Parsers/CMakeFiles/clickhouse_parsers.dir/ParserCreateHandlerQuery.cpp.o |
new | 63.99 KiB | +63.99 KiB |
src/Parsers/CMakeFiles/clickhouse_parsers.dir/ASTDropHandlerQuery.cpp.o |
new | 54.66 KiB | +54.66 KiB |
src/CMakeFiles/dbms.dir/Interpreters/checkValuelessSettingChanges.cpp.o |
new | 39.48 KiB | +39.48 KiB |
src/CMakeFiles/dbms.dir/Interpreters/InterpreterCreateHandlerQuery.cpp.o |
new | 39.01 KiB | +39.01 KiB |
src/CMakeFiles/dbms.dir/Interpreters/InterpreterDropHandlerQuery.cpp.o |
new | 36.29 KiB | +36.29 KiB |
src/CMakeFiles/dbms.dir/Access/ContextAccess.cpp.o |
930.83 KiB | 952.70 KiB | +21.86 KiB (+2.35%) |
src/CMakeFiles/dbms.dir/Storages/transformQueryForExternalDatabase.cpp.o |
169.55 KiB | 190.57 KiB | +21.03 KiB (+12.40%) |
src/Parsers/CMakeFiles/clickhouse_parsers.dir/ParserDropHandlerQuery.cpp.o |
new | 17.27 KiB | +17.27 KiB |
src/Parsers/CMakeFiles/clickhouse_parsers.dir/ASTLiteral.cpp.o |
346.04 KiB | 362.09 KiB | +16.05 KiB (+4.64%) |
737 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
3116 translation units recompiled, 20116 s compile time in total, 3102 of them have a recent master baseline.
Translation units without a recent master baseline:
src/Storages/System/StorageSystemHandlers.cpp: 7.3 ssrc/Common/SQLDefinedHandlers/SQLDefinedHandlersMetadataStorage.cpp: 6.0 ssrc/Interpreters/InterpreterCreateHandlerQuery.cpp: 5.7 ssrc/Interpreters/InterpreterDropHandlerQuery.cpp: 5.6 s
…ng-shared-validation # Conflicts: # tests/queries/0_stateless/04665_valueless_setting_ast_json_and_secret_parts.sh
|
🕵 The only red on d56a4ed was Merged |
…ng-shared-validation
|
🕵 Triage of the reds on 8366f42 (all unrelated to this change):
The AI review verdict on this revision is ✅ "No actionable findings" and there are no unresolved review threads. |
|
@alexey-milovidov Confirmed: that red is STID The fix PRs, and the one to prioritise
Both are absent from your build, verified at your sha What changed on 2026-08-06, which is the new part
A killed Rate, normalised so it is not a volume artifact. On The chain in your own log, from 2.26 seconds from the kill to the abort, on the same table. The killer logged 97 mutation kills in that run across many databases ( So the killer is not the bug, it is a good fuzzer that found a real one. My reading is that 112484 is what should land, because its check sits in On your numbers. "81 occurrences since 2026-07-09" reproduces: I get 87 rows across 75 pull requests with 5 on Session id: cron:clickhouse-premium-slot-26:20260808-042300 |
`ParserBackupQuery` accepts only `name = value` pairs, so the valueless form is parser-impossible for `BACKUP`/`RESTORE` settings, yet the tree walk treated their `ASTSetQuery` child as shorthand-capable and accepted a crafted `"shorthand": true, "value": true` payload. `BackupSettings` and `RestoreSettings` read `SettingChange::value` raw (numeric settings coerce Bool `true` to `1`), and `ASTSetQuery::formatImpl` would render the valueless form the backup grammar cannot parse back. Judge the context from the `ASTBackupQuery` parent, like the column-level and `EXPLAIN` cases, and cover `BACKUP`/`RESTORE` in the test. Co-Authored-By: Claude Fable 5 <[email protected]>
|
🕵 The Pushed 1988786 addressing the AI-review Blocker ( |
|
🕵 Both
Everything else is green, the AI review verdict is ✅ with no unresolved threads. Once either fix merges, a |
…ng-shared-validation
|
🕵 Merged |
…ng-shared-validation
|
🕵 Merged which is the stress harness's own verify query being fuzzed by the server-side AST fuzzer — unrelated to this PR and already fixed on Verified locally: incremental AI review verdict is ✅ "No actionable findings" and there are no unresolved review threads. |
|
🕵 Triage of the reds on c3bab7b (all unrelated to this change; both are the same fleet-wide
Neither fix has merged into |
…ng-shared-validation
|
🕵 Merged |
|
🕵 Triage of the reds on 3532c80 (both unrelated to this change — this PR only touches
@groeneai, investigate these two failures and provide fixes in separate PRs (and open tracking issues if none exist). If fixes are already in progress, link them here. |
|
Failure 1 ( The report is on the forced-exit path. The other three carriers are the same path: #113022 and #109454 both log Two things worth recording, since they differ from what I said on #112846 on 2026-08-08:
#114053 carries Failure 2 ( It is not the I have not reproduced it from ordinary SQL yet. The shapes I tried are rejected by the analyzer with |
…ng-shared-validation
|
🕵 Merged The other red,
Verified locally after the merge: incremental |
|
🕵 Triage of the only red on |
|
🕵 Closing as obsolete. Current |
Related: #113025
The valueless
SETTINGS nameform stands forname = true, and the SQL parser always writes Booltruefor it, so theshorthandflag paired with any other value is a parser-impossible shape that can only arrive from the AST JSON dialect. #113025 madeBaseSettings::checkShorthandChangereject it, but that only covers the settings applied throughBaseSettings.SettingsChangesare also consumed raw — theJoinengine readspersistentand its other settings directly,EXPLAINsettings never consult aBaseSettingsschema, and dictionary and data-lake settings have similar readers — and every such reader would execute the carried value for a change that claims to be valueless.Instead of duplicating the check in each raw reader, reject the shape once for the whole query tree in
executeQueryImpl, for ASTs deserialized from the JSON dialect. The check deliberately runs afterquery_for_loggingis prepared, so the exception is logged with the AST masked rather than with the raw JSON text — the same reason the shape is not rejected at deserialization.Because the tree-wide check has no settings schema, it fires before the per-setting type check, so the crafted payload in
04665_valueless_setting_ast_json_and_secret_partsnow reportsBAD_ARGUMENTS(carries a value despite claiming the valueless form) instead ofTYPE_MISMATCH; the genuine valueless forms and their error codes are unchanged, and the masked-logging assertion still holds.This addresses the remaining review finding on #113025.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Reject a setting change that is marked as the valueless
SETTINGS nameform but carries a value other thantruefor every consumer of settings (e.g. theJoinengine orEXPLAINsettings), not only for the settings applied throughBaseSettings. Such a change can only be produced by the experimental AST JSON dialect.