Repository navigation
Settings history style check: surface removed records - #112782
Conversation
Follow-up to #111841, which left an unresolved review finding: deleting the last history row of a setting was a silent escape hatch. `parse_settings_history_changes` returned `[]` for pure removals and `check_settings_changes_history` treats an empty list as "nothing to validate", so a change that reverts a compiled default to an older value could delete the row that recorded the original change instead of recording the revert under the current version block, and stay green. `03999_stateless_settings_history` does not catch it either: it only compares the current default with the *newest* recorded `new_value`. The result is that `compatibility` hands out the wrong value for the release that shipped the other default. The parser now reports removed records as well, with the namespace taken from the enclosing block just as for added lines. Records moved between blocks and reason-only edits are still ignored (their value-signature appears on both sides of the diff). Deleting a phantom record remains possible: such a change touches only `SettingsChangesHistory.cpp`, and the source-file gate in `check_settings_changes_history` lets it through. Pinned by new cases in `ci/tests/test_settings_history_diff_parser.py` and an end-to-end case in `ci/tests/test_settings_history_source_gate.py`.
|
Workflow [PR], commit [1f691e0] Summary: ✅ AI ReviewSummaryThis PR extends the settings-history style check so removals, moves, and Findings❌ Blockers
Final VerdictChanges required. |
`parse_settings_history_changes` suppressed any added or removed entry whose value-signature appeared on the other side of the diff, which covered both reason-only edits and records *moved* between blocks. That left the escape hatch open in "move instead of delete" form: re-adding an unchanged record under an older version block keeps the newest recorded value intact, so `03999_stateless_settings_history` still passes, while `compatibility` starts attributing the default flip to the release of the older block. The suppression key now includes the enclosing block - namespace and version - resolved for both sides of the diff, so only a reason-only edit of an entry that stays in its block is ignored; a move to another version or namespace block is reported once and `check_settings_changes_history` then requires the setting under the current version block. A removed line is resolved from the new-file line *before* the diff position, so dropping the last entry of a block is not attributed to the block that follows. New cases in `ci/tests/test_settings_history_diff_parser.py` (move to an older block, move between namespaces, reorder inside one block) and an end-to-end case in `ci/tests/test_settings_history_source_gate.py`.
…moval-escape-hatch
…nges` header changed A block header edit reassigns every record underneath it to another release or namespace without touching a single entry line, so the entry-level scan in `parse_settings_history_changes` returned `[]` and `check_settings_changes_history` treated the change as "nothing to validate" - the same `compatibility` misattribution hole, at block granularity. The parser now records added and removed `addSettingsChanges` header lines and reports every entry of the affected block. A header rewritten in place is covered by the added header at that position; a header that is only removed merges its records into the block above, which is reported instead.
| # only costs an extra name in a message that is already failing for the removed rows. | ||
| if lineno in headers_added: | ||
| continue | ||
| header_index = _settings_history_block_header_index(file_lines, lineno - 1) |
There was a problem hiding this comment.
Deleting the first addSettingsChanges block still comes back as [] here, so the escape hatch remains open for the current-version block. With a patch that removes the leading 26.8 block, both headers_removed and removed-entry resolution walk to lineno - 1; in the post-image there is no preceding header, so _settings_history_block_header_index returns None and parse_settings_history_changes reports nothing. check_settings_changes_history then treats a PR that deletes the whole current block and changes src/Core/Settings.cpp as "nothing to validate".
This needs to resolve a removed block against the removed header / removed entries themselves (old-side diff state), not only against the preceding block in the post-image. Please add a regression test for deleting the first block.
`store_data.py` conflicted with the merged ClickHouse#112782, which extended `parse_settings_history_changes` to also report value-edits, removals, moves between `addSettingsChanges` blocks and block-header edits. Union resolution, verified by AST rather than by reading: the two sides add disjoint top-level symbols at the same anchor (`fetch_settings_history_patch`, `settings_history_fetch_error_message`, `store_settings_history_changes`, `SETTINGS_HISTORY_FILE` here; `_settings_history_block_at`, `_settings_history_block_entries`, `_settings_history_block_header_index`, `_SETTINGS_HISTORY_BLOCK_END_RE` there), zero name collisions, and `parse_settings_history_changes` keeps master's signature and body byte-identical, so the parser rewrite is taken whole and the fetch/diagnostic machinery is preserved whole. The second hunk is this branch's extraction of the inline fetch into `store_settings_history_changes` against master's comment update in `__main__`. Kept the extracted form and adopted master's semantic wording; master's `settings_history_file` local and its `Best-effort` tail are dead under the fail-close design this branch introduces, so they are dropped rather than merged. Verified against the merged tree: this branch's 24 tests pass unchanged, as do all 49 tests across the three settings-history modules, including master's own `test_settings_history_source_gate.py` cells for removals, moves and header edits. Full `ci/tests` run shows no new failure - the 7 remaining are a subset of the 20 a pristine `origin/master` `ci/` tree produces on this host, and none of the 3 failing modules reaches a changed file through its transitive import closure. No `contrib` gitlink drift.
Follow-up to #111841 (merged), which left one unresolved review finding.
Deleting the last history row of a setting was a silent escape hatch.
parse_settings_history_changesreturned[]for pure removals, andcheck_settings_changes_historytreats an empty list as "nothing to validate", so a change that reverts a compiled default to an older value could delete the row that recorded the original change instead of recording the revert under the current version block, and both guards stayed green —03999_stateless_settings_historyonly compares the current default with the newest recordednew_value. The consequence is thatcompatibilityhands out the wrong value for the release that actually shipped the other default.The diff parser now reports removed records too, with the namespace taken from the enclosing
addSettingsChangesblock just as for added lines. Records moved between blocks and reason-only edits are still ignored, because their value-signature appears on both sides of the diff. Deleting a phantom record remains possible: such a change touches onlySettingsChangesHistory.cpp, and the source-file gate incheck_settings_changes_historylets it through.Pinned by new cases in
ci/tests/test_settings_history_diff_parser.pyand an end-to-end case inci/tests/test_settings_history_source_gate.py(16 tests pass,ruff checkclean).Related: #111841
Related: #111605
Changelog category (leave one):
Version info
26.8.1.642(included in26.8and later)