Repository navigation
Throw on unknown configuration option in server config - #100332
Conversation
Previously, wrong or misspelled configuration entries in the server config were silently ignored, making it hard to diagnose configuration issues (e.g., `<max_thred_pool_size>` would be silently ignored). Added `ServerSettings::checkUnknownSettings` that validates all top-level config keys against known ServerSettings entries and a comprehensive list of known complex config sections. Throws `UNKNOWN_ELEMENT_IN_CONFIG` if an unrecognized key is found. The check is called on both server startup and config reload, and respects the existing `skip_check_for_incorrect_settings` escape hatch. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Workflow [PR], commit [7629905] Summary: ✅
AI ReviewSummaryThis PR adds Findings
Final VerdictRequest changes. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 611/691 (88.42%) · Uncovered code |
…gration tests Address review feedback and fix CI failures: - Add `instrumentation_trace_log` to known system log sections (present in default `programs/server/config.xml`, caused Fast Test server startup failure) - Add `allow_experimental_cluster_discovery` to known cluster sections - Add `lemmatizers`, `synonyms_extensions`, `catboost_lib_path`, `path_to_regions_hierarchy_file`, `path_to_regions_names_files` to known dictionaries/functions sections - Add `transaction_log` to known miscellaneous sections Fix integration tests that use custom top-level config keys: - `test_http_handlers_config`: uses arbitrary config key referenced via `config://` in HTTP handler static responses - `test_database_hms`: uses non-standard `experimental_features` section Both tests now set `skip_check_for_incorrect_settings` to bypass the check. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…ndling - Add command-line option names (`pid-file`, `config-file`, `log-file`, `errorlog-file`) to the known config sections allowlist. These keys are injected into the config by `argsToConfig` which processes all argv entries, including Poco options that were already handled via bindings. - Dynamically extract top-level keys referenced via `config://` in `http_handlers` `response_content`/`response_expression` fields and whitelist them. This preserves backward compatibility for deployments using custom config-backed static HTTP responses via `StaticRequestHandler`. - Remove the `skip_check_for_incorrect_settings` workaround from the `test_static_handler` integration test config, since the dynamic extraction now properly handles it. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…ig allowlist
The `pid-file` Poco option has `.binding("pid")`, so Poco stores the
value under the key `pid` in the config — causing `UNKNOWN_ELEMENT_IN_CONFIG`
on server startup.
Also add hyphen-less variants (`pidfile`, `configfile`, `logfile`,
`errorlogfile`) since `argsToConfig` stores raw CLI key names without
normalization.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Poco's `SystemConfiguration` injects a `system` top-level key into the
layered configuration. When `checkUnknownSettings` enumerates all
top-level keys via `config.keys("")`, it sees this Poco-internal key
and rejects it with `UNKNOWN_ELEMENT_IN_CONFIG`, preventing server
startup (as seen in the Fast test CI failure).
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add a test that verifies the server rejects unknown top-level config keys with `UNKNOWN_ELEMENT_IN_CONFIG`. This ensures future allowlist edits don't silently reintroduce startup exceptions or allow invalid keys through. The existing `test_http_handlers_config/test_static_handler` test already validates that custom top-level keys referenced via `config://` pass validation without `skip_check_for_incorrect_settings`. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
… allowlist, fix integration test - Add `core_path` to `known_complex_sections` — this key is read by `BaseDaemon` for the core dump directory and is used in stress test configs. Missing it caused all stress tests and install tests to fail with `UNKNOWN_ELEMENT_IN_CONFIG`. - Add `experimental_features` to `known_complex_sections` and remove the `skip_check_for_incorrect_settings` workaround from `test_database_hms/config.xml` (per review feedback). - Fix `test_unknown_config_option` integration test: when the server fails to start, the error message goes to the error log file (via `--errorlog-file`), not to container stdout. Read the error log from the host-mounted logs directory so the assertion can find the `UNKNOWN_ELEMENT_IN_CONFIG` message. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
The failures of "Flaky check" in "functions_bad_arguments" will be fixed by #101994. |
- Add `daemon`, `umask`, `help`, `version` to the known config sections allowlist. These are injected by Poco `ServerApplication` and `argsToConfig` when the server is started with `--daemon --umask` etc. Without this, those startup flows throw `UNKNOWN_ELEMENT_IN_CONFIG`. - Tighten prefix-based matching for dynamic config sections (`graphite_rollup`, `http_handlers`, `users`) to require an exact match or prefix followed by `_` separator. Previously, bare `starts_with` would silently accept typos like `graphite_rollupTypo`. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This key is used in the AST fuzzer config (`fuzz-server-settings.xml`) for shared catalog support. Without it, the server fails to start with `UNKNOWN_ELEMENT_IN_CONFIG` during fuzzer CI runs. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
The MSan stress test failure (MemorySanitizer: use-of-uninitialized-value, STID 4179-5154 or 4148-3044) is a known pre-existing issue unrelated to this PR. Fix: #102158 |
Since #100332, a server refuses to start when the config contains an unknown top-level key. The perf-comparison 'master_head' jobs start the Reference server from the latest master binary with this PR checkout's config, which sets `columns_cache_size` — a key that master does not know yet — so all 12 shards failed at "Start" with `UNKNOWN_ELEMENT_IN_CONFIG`. Keep the cache disabled in the perf-comparison environment but set `skip_check_for_incorrect_settings` so the older binary can start. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96844&sha=e66ac61cb546f235a1e2768e2a076f5fc7dc2f25&name_0=PR&name_1=Performance%20Comparison%20%28amd_release%2C%20master_head%2C%201%2F6%29 Co-Authored-By: Claude Fable 5 <[email protected]>
|
Closing the loop on the
One variant worth not conflating with this one: the same message text is still live from |
Fix Fast test "Start ClickHouse Server" failure caused by stock config containing top-level `<histogram_metric_log>` section, which was not in the `known_complex_sections` allowlist. Also allow `log` and `errorlog` top-level keys, mirroring the existing `config` entry: Poco's `OptionProcessor` resolves `--log` and `--errorlog` as prefix abbreviations of `--log-file` and `--errorlog-file`, and `argsToConfig` stores the raw CLI key in the config layer. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100332&sha=ddee8e063769cfb202fcc861184fc0270108fdb3&name_0=PR&name_1=Fast%20test PR: ClickHouse#100332 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The new `predicate_statistics_log` system log was added to master after this branch diverged. It is included in the default test config, so the fast test fails at startup with `UNKNOWN_ELEMENT_IN_CONFIG`. CI report: ClickHouse#100332 Fast test failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100332&sha=31406922f03756e014ca8aaafecaa661d42d8959&name_0=PR&name_1=Fast%20test
The reload cluster started with `static_handler_config_ref.xml`, which already provides an `<http_handlers>` section with a single `<rule>` that references `config://my_static_response_payload`. The test then injected a second `<http_handlers>` section (from `reload_payload.xml`) that referenced `config://my_reload_payload`. `ConfigProcessor::mergeRecursive` matches sibling elements by name + attributes, so the two `<rule>` elements (and the two `<defaults/>` markers) collapsed into one. Whichever file was merged last (the alphabetical order put `static_handler_config_ref.xml` after `reload_payload.xml`) overwrote the other rule's `<url>` and `<response_content>` text. The merged config kept `<my_reload_payload>` as a top-level key but lost the `config://my_reload_payload` reference, so `checkUnknownSettings` rightly rejected the orphaned key with `UNKNOWN_ELEMENT_IN_CONFIG`. Switch the reload cluster to a minimal placeholder `reload_initial.xml` so there is no pre-existing `<http_handlers>` to collide with the rules injected at runtime. CI report: ClickHouse#100332 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
`clickhouse-private` test configs introduce additional top-level sections used by SharedCatalog, distributed cache, and stateless workers. Without them in the allowlist, the new validation throws `UNKNOWN_ELEMENT_IN_CONFIG` at server startup in private CI: - `shared_merge_tree` - `distributed_cache_client` - `distributed_cache_server` - `distributed_query` - `stateless_worker_client` - `stateless_worker_server` - `_functional_tests_helper_shared_catalog` Confirmed by the "CH Inc sync" failure on ClickHouse/clickhouse-private#53245 (sync PR for ClickHouse#100332): every SharedCatalog / distributed-cache / meta-in-keeper test job reports "Failed to start ClickHouse replica 0" with no client connection on `localhost:9000`.
…wlist The private CI integration test job `test_shared_catalog/test.py::test_server_uuid_from_replica_name` fails to start the server because `checkUnknownSettings` rejects two top-level keys consumed only by private builds: - `server_uuid_from_replica_name` — read in `programs/server/Server.cpp` to derive the server UUID from `macros.replica` for SharedCatalog. - `cloud` — used for `cloud.readiness` (`CloudReadinessHandler`) and `cloud.port` in `programs/server/Server.cpp`. Both keys are absent from public ClickHouse, so they only appear in the private allowlist. Without them every SharedCatalog-enabled integration test job in the sync PR fails with `UNKNOWN_ELEMENT_IN_CONFIG` at server startup. Confirmed by the failing jobs in the sync PR ClickHouse/clickhouse-private#53245 (sync of ClickHouse#100332): all `Integration tests (amd_*, db disk, ...)` and `Integration tests (amd_tsan / amd_msan, ...)` shards fail at setup of `test_server_uuid_from_replica_name` with the same exception.
…list
The previous commit (`Address review: drop blanket users_* prefix allowlist`)
made the unknown-config check reject any top-level `users_*` keys in the
main config. That broke `test_config_substitutions` because it placed the
include source file (`include_from_source.xml`/`yml`) under `main_configs=`,
which causes the integration test framework to copy it into `config.d/`.
Files in `config.d/` are auto-loaded as part of the main config, so the
file's top-level keys (`<users_1>`, `<users_2>`) leaked into the merged
main config and tripped `checkUnknownSettings`:
Code: 137. DB::Exception: Unknown element 'users_1' found in config
/etc/clickhouse-server/config.xml. (UNKNOWN_ELEMENT_IN_CONFIG)
These files are not real main configs - they are pure substitution sources
referenced by `<include_from>`. The fix is to use `extra_configs=` instead,
which copies them to `extra_conf.d/` (a directory ClickHouse does not
auto-load) and update the `<include_from>` paths accordingly.
CI report:
ClickHouse#100332
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…op-level config keys Cloud runs were failing with `UNKNOWN_ELEMENT_IN_CONFIG` for `enable_http_stacktrace`, which is a real top-level config option consulted by `HTTPHandler` (see `src/Server/HTTPHandler.cpp`) and `enable_verbose_replicas_status` is consulted by `ReplicasStatusHandler` (see `src/Server/ReplicasStatusHandler.cpp`). Both are documented in the example `programs/server/config.xml`. Reported by @yurifedoseev on PR ClickHouse#100332.
Cloud runs were failing with `UNKNOWN_ELEMENT_IN_CONFIG` for `format_alter_operations_with_parentheses`, a legacy server config setting whose default flipped to true in 25.2 (see ClickHouse#75302) and is no longer consulted in the public codebase. Long-lived cloud configs may still carry the key as leftover state, so add it to the obsolete-key allowlist to keep upgrading installations starting cleanly. Reported by @yurifedoseev on PR ClickHouse#100332.
`StaticRequestHandler` accepts `config://` lookups with Poco's bracket-index path syntax (e.g. `config://my_payload[1]` to select the second instance of a repeated top-level key, or `config://my_payload[1].field`). Previously the validator stripped the path at the first `.` but kept any `[index]` suffix, so `referenced_keys` ended up holding `my_payload[1]`. The corresponding `top_level_keys` are normalized by stripping `[index]` before the membership check, so the lookup of `my_payload` (and of `my_payload[1]` after its own normalization) missed the recorded reference and produced a spurious `UNKNOWN_ELEMENT_IN_CONFIG`. Normalize the reference the same way by truncating at the first `.` or `[` when recording it. Added an integration test that exercises a repeated top-level key referenced via `config://my_indexed_payload[1]`. Reported by @yurifedoseev on PR ClickHouse#100332.
`test_config_substitutions` puts `<include_from>` in a `users.d/` fragment and keeps the substitution source under `config.d/`. The earlier fix only read `include_from` from the main config, so node4 still tripped `UNKNOWN_ELEMENT_IN_CONFIG` on `users_1` / `users_2` / `mqs` after the substitution source leaked into the merged main config. Now scan all standard config files (main config, `config.d/`, users config, `users.d/`) for: 1. `incl="X"` attributes — `X` is a top-level key in the substitution source. 2. `<include_from>` elements — parse the referenced source and exempt its top-level keys (preserves the previous broader exemption). The check is best-effort (parse failures are tolerated) so a malformed fragment elsewhere in the directory does not cause a false negative. See https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100332&sha=686d83c3f55aa655de5ea287fce40617dfead60e&name_0=PR&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20targeted%29 PR: ClickHouse#100332 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
When `<include_from>` uses a `from_env` or `from_zk` attribute, the raw XML has an empty `innerText()`, so the previous scan did not pick up the resolved path. Top-level keys from the include source could then leak into the merged main config as unrecognized keys and trip `UNKNOWN_ELEMENT_IN_CONFIG`. Two complementary fixes: * When scanning raw XML, resolve `from_env="VAR"` on `<include_from>` via `std::getenv` and use it as the source path. * Additionally, read the already-substituted `include_from` value from the merged `config` parameter (it covers `from_zk` and any other substitution form `ConfigProcessor` resolved before us). Addresses review feedback on PR ClickHouse#100332. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The private/enterprise `<jwt_authenticators>` config section (parsed in `ExternalAuthenticators` and referenced by static users via `<jwt_authentication>`) was not in the `checkUnknownSettings` allowlist, so the server threw `UNKNOWN_ELEMENT_IN_CONFIG` on startup and failed to start. This broke the private integration tests `test_jwt_static_users` and `test_jwt_static_users_with_jwks`, surfacing as the `CH Inc sync` failure. Add `jwt_authenticators` alongside the other authentication sections (`jwt`, `ldap_servers`, `kerberos`, `http_authentication_servers`). Found via the `CH Inc sync` report for PR ClickHouse#100332: ClickHouse/clickhouse-private#53245 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…onfig.xml` This PR removed `tests/integration/test_database_hms/config.xml` (a dead `<experimental_features>` section that no C++ code reads) and dropped the `main_configs` reference from `test.py`. Meanwhile, `test_ttransport_exception_reproduction.py` was added on master with the same `main_configs=["config.xml"]` reference, so after merging master the test failed with `FileNotFoundError` in all integration shards. Apply the same change as in `test.py`: the two experimental settings are user/profile settings already defined in the test's `users.xml`, which the test loads via `user_configs`. CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100332&sha=b82c9682bfc4a7b0fdb9e694914e4c510fc8000d&name_0=PR&name_1=Integration%20tests%20%28amd_msan%2C%203%2F6%29 PR: ClickHouse#100332 Co-Authored-By: Claude Fable 5 <[email protected]>
On `SYSTEM RELOAD CONFIG`, `Settings::checkNoSettingNamesAtTopLevel` validates the file-only `loaded_config` (so that a failed reload does not leave the layered `config()` partially mutated), but that file-only config does not carry command-line options. As a result `--skip_check_for_incorrect_settings=1` no longer suppressed this pre-existing top-level user-setting check on reload, even though it still does at startup. Gate the call on the escape hatch resolved from the layered `config()`, mirroring what `checkUnknownSettings` already does. Addresses the review finding at programs/server/Server.cpp:2335 (ClickHouse#100332 (comment)).
1. Arbitrary-named `GraphiteMergeTree` rollup sections. The rollup config section
name is taken from the table definition (`GraphiteMergeTree('<section>')`), so
it can be any name, not only `graphite_rollup*`. Such a section was valid
before this check existed and was wrongly rejected at startup with
`UNKNOWN_ELEMENT_IN_CONFIG`. Recognize it by its structure (a `<pattern>` or
`<default>` carrying `<regexp>`/`<function>`/`<retention>`) so it is accepted
while unstructured typos are still rejected.
2. External `<include_from>` substitution sources. `ConfigProcessor` reads an
external `<include_from>` source only as a lookup table for `incl` references;
it does not add the source document's top-level tags to the merged config.
Exempting those tags unconditionally let a genuinely unknown top-level key pass
merely because the lookup table happened to define a tag of the same name.
Only exempt a source's top-level tags when the source file is itself merged
into the server config (it lives under `config.d`/`conf.d`); canonicalize paths
so symlinks do not defeat the membership test.
Addresses the review findings at src/Core/ServerSettings.cpp:2132
(ClickHouse#100332 (comment))
and src/Core/ServerSettings.cpp:2336
(ClickHouse#100332 (comment)).
clickhouse-benchmark uses the default handshake_timeout_ms=10000 (10s) and connect_timeout=10s. On slow lanes (amd_tsan, s3 storage, parallel) the TLS handshake to the secure port can take longer than 10s under load, so the client aborts with Code: 209 DB::NetException Timeout exceeded (SOCKET_TIMEOUT) before certificate verification runs. That breaks both checks: the first invocation loses its expected "certificate verify failed" line, and the SOCKET_TIMEOUT text trips grep Exception in the second invocation. "Server died" is the harness verdict from the same slow-response window, not a crash. Add --connect_timeout 60 --handshake_timeout_ms 60000 to the benchmark invocations so the handshake has a generous budget on slow lanes. The test still verifies the same behavior: --secure without --accept-invalid-certificate still prints "certificate verify failed", and --secure --accept-invalid-certificate still succeeds with no exception. Same approach as 01600_benchmark_query (ClickHouse#108570) and 03636_benchmark_error_messages (ClickHouse#103298, ClickHouse#103668). Reported on ClickHouse#100332 by alexey-milovidov. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…_disk_remote_url_allow_hosts Both instances start from clickhouse/clickhouse-server:26.8.26.12 with the fork's config.xml, and since ClickHouse#100332 an upstream server refuses it: `Unknown elements 'cas_log', 'cas_gc_log' found in config /etc/clickhouse-server/config.xml (UNKNOWN_ELEMENT_IN_CONFIG)`. Set skip_check_for_incorrect_settings for these two instances only. CI: https://altinity-build-artifacts.s3.amazonaws.com/PRs/2805/8c26e8792eb4d675d6cfa59b06f8e31b38471008/integration_tests_amd_asan_ubsan_targeted/logs.tar.gz PR: #2805 Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Mikhail Filimonov <[email protected]>
Both instances start from `clickhouse/clickhouse-server:26.8.26.12` with the fork's `config.xml`, and since ClickHouse#100332 an upstream server refuses it: `Unknown elements 'cas_log', 'cas_gc_log' found in config /etc/clickhouse-server/config.xml (UNKNOWN_ELEMENT_IN_CONFIG)`. Set `skip_check_for_incorrect_settings` for these two instances only. The test is `test_custom_s3_disk_remote_url_allow_hosts`. CI: https://altinity-build-artifacts.s3.amazonaws.com/PRs/2805/8c26e8792eb4d675d6cfa59b06f8e31b38471008/integration_tests_amd_asan_ubsan_targeted/logs.tar.gz PR: #2805 Signed-off-by: Mikhail Filimonov <[email protected]> Co-Authored-By: Claude Fable 5.2 <[email protected]>
Previously, wrong or misspelled configuration entries in the server config were silently ignored, making it hard to diagnose configuration issues (e.g.,
<max_thred_pool_size>would be silently ignored instead of alerting the user).Added
ServerSettings::checkUnknownSettingsthat validates all top-level config keys against knownServerSettingsentries and a comprehensive list of known complex config sections. ThrowsUNKNOWN_ELEMENT_IN_CONFIGif an unrecognized key is found.The check runs on both server startup and config reload. It respects the existing
<skip_check_for_incorrect_settings>escape hatch.Known keys come from three sources:
ServerSettingsscalar setting names (settings without paths)ServerSettingspath-based settings (e.g.,logger,openSSL,distributed_ddl)graphite_rollup_*,http_handlers_*)Sections referenced from elsewhere in the config (
inclsubstitutions,config://references in HTTP handlers, custom protocol handler sections, and top-level tags ofinclude_fromsource files kept underconfig.d/) are exempt from the check.Known limitation (ZooKeeper-backed substitutions): resolving a
from_zksubstitution would require a ZooKeeper connection at config-validation time, before the<zookeeper>section itself has been validated, so:<include_from>is specified with afrom_zksubstitution inside a users-config fragment and its source file is kept underconfig.d/, the source's top-level tags are not exempted. Such setups can either move the substitution source out ofconfig.d/or set<skip_check_for_incorrect_settings>.<include from_zk=.../>(which imports the referenced ZooKeeper node's children as top-level keys), the whole check is skipped for that config, with a warning, so a valid config is never rejected — but a genuine typo alongside such an include is not caught.Literal paths,
from_env(including a top-level<include from_env=.../>), the default/etc/metrika.xmlsubstitution source, andinclin the main server config are all covered.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The server now refuses to start (and rejects
SYSTEM RELOAD CONFIG) when the server config contains an unknown top-level element, instead of silently ignoring it. Audit your config before upgrading: stale sections left over from older versions, sections consumed by forks/third-party tooling, and no-op marker sections will now abort startup withUNKNOWN_ELEMENT_IN_CONFIG. Set<skip_check_for_incorrect_settings>1</skip_check_for_incorrect_settings>(or pass--skip_check_for_incorrect_settings=1) to restore the previous behavior.Documentation entry for user-facing changes
🤖 Generated with Claude Code
Version info
26.8.1.1144(included in26.8and later)