Repository navigation
Name the setting when its value is rejected - #116882
Conversation
A survey pass over settings, table functions and window functions found
that a setting given a value of the wrong type or out of range is
reported without saying which setting it was:
SELECT 1 SETTINGS max_threads = 'abc'
Cannot parse input: expected 'eof' before: 'abc'
SELECT 1 SETTINGS max_block_size = 0
A setting's value has to be greater than 0
SELECT 1 SETTINGS max_threads = -1
Field value -1 is out of range of unsigned long type
The message is produced by the setting's own field, which does not know
its name. `castValueUtil` is where a value from a `SETTINGS` clause or
from `SET` is checked, and `set` is where one from the server config is
applied, so name the setting and the value there - which is what
`stringToValueUtil` next to them already does for the command line:
Cannot parse input: expected 'eof' before: 'abc': while setting
'max_threads' to value 'abc'
An unknown setting name is left alone: that message already names it and
suggests a correction, so the lookup happens outside the block that adds
the context.
`ServerSettings::loadSettingsFromConfig` had its own "while parsing
setting '{}' value" wrapper, which is now redundant, so it is removed and
`test_validate_threadpool_writer_pool_size` is updated for the wording it
produces instead - the same information, in the same place for all paths.
|
Workflow [PR], commit [efc493e] Summary: ✅
AI ReviewSummaryThis PR improves rejected-setting diagnostics across query, config, and Findings
Final VerdictChanges requested. LLVM Coverage ReportMeasured on commit efc493e.
Changed lines: Changed C/C++ lines covered: 45/54 (83.33%) · Uncovered code |
`Fast test` reported
Setting max_threadz is neither a builtin setting nor started with the prefix
'SQL_' or 'custom_' registered for user-defined settings: Maybe you meant
['max_threads'].
where the test expected `Unknown setting 'max_threadz': Maybe you meant
['max_threads'].` - the wording depends on whether custom-setting prefixes
are configured, which the stateless test config does and a bare server
does not. Both forms are what this change is about leaving alone, so
assert the two things that matter instead of the text: the hint survives,
and no `: while setting ...` context is appended to it.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units1925 translation units recompiled, 11432 s compile time in total, 1925 of them have a recent master baseline. |
…t the startup exception text outside `pytest.raises` - Resolve the setting name outside the `try` in `BaseSettings::set`, the same way `castValueUtil` does, so an `UNKNOWN_SETTING` error from `getCustomSetting` does not get the `while setting ...` context appended (e.g. `CREATE TABLE ... ENGINE = Memory SETTINGS typo = 1` keeps its original diagnostic). - In `test_validate_threadpool_writer_pool_size`, move the assertion below the `with pytest.raises(...)` block: `cluster.start()` raises, so the assertion was unreachable. - In test 05052, normalize `unsigned long long` (macOS) to `unsigned long` (Linux) - the platform name of `UInt64` differs, which failed Fast test (arm_darwin): https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=116882&sha=8c44211c61e5f27121676c1754c0afe631a12e89&name_0=PR&name_1=Fast%20test%20%28arm_darwin%29 #116882
…ue-error-messages
Master gained `05052_client_untrusted_server_allocations` and two 05053 tests, so the test from this PR moves to the next free number.
The exception from `cluster.start` embeds the container's stdout, where the server only reports `Server exited with 36` - the full exception text goes to the error log, which the test already asserts on below. Verified by running the integration test locally: the message `while setting 'threadpool_writer_pool_size' to value '0'` appears in the error log, and the startup exception carries the exit code.
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=116882&sha=8c44211c61e5f27121676c1754c0afe631a12e89&name_0=PR&name_1=Stress%20test%20%28arm_msan%29 ( |
|
The fix is already in progress: #108357 ( I confirmed the attribution from Its processlist row: The carrier is #108357 adds In case tagging looks like the cheaper route: the test already carries |
…ue-error-messages
`SettingFieldURI` built `Poco::URI` directly, so a malformed value such as `SETTINGS format_avro_schema_registry_url = 'http://['` escaped as a `Poco::SyntaxException`, which is not a `DB::Exception` and therefore bypassed the new "while setting '<name>' to value <value>" context. `SettingFieldURI::parseURI` now converts it into a `BAD_ARGUMENTS` exception. The echoed value is passed through `maskURIPassword`, so a URI setting that carries basic-auth credentials does not print the password in the message. The stateless test covers both: the setting is named and the password is masked.
…ue-error-messages
… too `BaseSettings::stringToValueUtil`, which converts settings profiles and constraints from `users.xml`, still appended the raw value to a rejected value's message, so a malformed `format_avro_schema_registry_url` carrying basic-auth credentials leaked the password in the startup exception. Add a `String` overload of `BaseSettingsHelpers::formatValueForErrorMessage` and route that path through it, using the same wording as the `Field`-based `set` and `castValueUtil` paths. Also move the misplaced comment of `warningSettingNotFound` back to it. The new test drives the `users.xml` parser through `clickhouse-local` with a config file that points `users_config` at itself, covering profiles and constraints. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ue-error-messages # Conflicts: # src/Core/SettingsFields.cpp
| BaseSettingsHelpers::throwSettingNotFound(name); | ||
| } | ||
|
|
||
| /// This is where a value given in a `SETTINGS` clause or by `SET` is checked, so it is where the |
There was a problem hiding this comment.
compatibility still bypasses this new wrapper. SettingsImpl::set special-cases that name before it reaches BaseSettings::set (src/Core/Settings.cpp:9970-9974) and calls applyCompatibilitySetting directly, while ClickHouseVersion still throws a bare Cannot parse ClickHouse version here: ... for malformed input (src/Common/ClickHouseVersion.cpp:24-31).
As a result, SET compatibility = '26.bad' or SELECT 1 SETTINGS compatibility = '26.bad', max_threads = 'abc' still lacks the while setting 'compatibility' to value ... context this PR promises, so a long SETTINGS list can still leave the user guessing which setting failed. Please wrap that branch with the same suffix and add a focused stateless test for an invalid compatibility string.
Official builds end an exception message with `(version 26.10.1.1 (official build))`. The `sed` pattern ` (version [^)]*)$` cannot match the nested parentheses, so the suffix stayed in the output and `05059_setting_value_error_names_the_setting` failed in the merge queue, while it passed on builds that print just `(version X)`. Strip everything from ` (version ` to the end of the line instead, in both tests. https://github.com/ClickHouse/ClickHouse/actions/runs/35940688467/job/107451385431 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Related: #116806
Related: #116809
Related: #116812
Related: #116815
Related: #116817
Related: #116871
Related: #116877
A survey pass over settings, table functions and window functions — as part of the wider survey of error messages for mistakes in SQL queries — found most of those answered well (an unknown setting is corrected, a bad enum lists the accepted values, an unknown table function and a bad window frame are named). One thing was not: a setting given a value of the wrong type or out of range is reported without saying which setting it was.
SELECT 1 SETTINGS max_threads = 'abc'Cannot parse input: expected 'eof' before: 'abc'SELECT 1 SETTINGS max_block_size = 0A setting's value has to be greater than 0SELECT 1 SETTINGS max_threads = -1Field value -1 is out of range of unsigned long typeSELECT 1 SETTINGS max_memory_usage = '10 elephants'Cannot parse input: expected 'eof' before: ' elephants'None of them names the setting, which for a query or a profile with a long
SETTINGSlist leaves the user to guess. The messages come from the setting's own field, which does not know its name — but the two places that reach it do.castValueUtilis where a value from aSETTINGSclause or fromSETis checked, andsetis where one from the server config is applied, so the context goes there, andstringToValueUtilright next to them, which converts settings profiles and constraints fromusers.xml, now uses the same wording:An unknown setting name is deliberately left alone — that message already names it and suggests a correction — so the lookup happens outside the block that adds the context:
SettingFieldURIused to buildPoco::URIdirectly, so a malformed URI value (SETTINGS format_avro_schema_registry_url = 'http://[') escaped as aPoco::SyntaxExceptionthat is not aDB::Exceptionand bypassed the context. It is now converted into aBAD_ARGUMENTSexception, and the value echoed in the context goes throughmaskURIPassword, so a URI setting that carries basic-auth credentials is reported ashttp://user:[HIDDEN]@.... The same masking applies on the string-basedstringToValueUtilpath, so a malformed URI in ausers.xmlprofile or constraint does not leak the password in the startup exception either.ServerSettings::loadSettingsFromConfighad its ownwhile parsing setting '{}' valuewrapper for the config path, which is now redundant; it is removed so that one place produces the context for every path, andtest_validate_threadpool_writer_pool_sizeis updated for the wording it produces instead (the same information).The 79 stateless tests that mention
UNKNOWN_SETTING,CANNOT_CONVERT_TYPEor a rejected setting value were run; the failures are unrelated environment ones (no ZooKeeper, no test clusters, no external databases in the local setup).Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A setting given a value of the wrong type or out of range now names the setting and the value in the error message —
Cannot parse input: expected 'eof' before: 'abc': while setting 'max_threads' to value 'abc'instead of justCannot parse input: expected 'eof' before: 'abc'. Previously the message came from the setting's field, which does not know its own name, so a query with a longSETTINGSlist gave no clue which setting was at fault.Workflow [PR]
Sync PR [sync-upstream/pr/116882]
Version info
26.10.1.621-master(included in26.10and later)