Skip to content

Report the real reason when the settings-history diff fetch fails - #112970

Merged
maxknv merged 9 commits into
ClickHouse:masterfrom
groeneai:ci-settings-history-fetch-error-reporting
Aug 7, 2026
Merged

maxknv merged 9 commits into
ClickHouse:masterfrom
groeneai:ci-settings-history-fetch-error-reporting

Conversation

@groeneai

@groeneai groeneai commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

...

Description

The Style check / settings_changes_history validator needs the diff of
src/Core/SettingsChangesHistory.cpp, which store_data.py fetches from the GitHub API. That
fetch had no retries and never reported why it failed.

Root cause. Shell.get_output defaults to strict=False: one attempt, and on a non-zero exit
it warns and returns stdout anyway, i.e. an empty string. if patch.strip() in ("", "null") then
relabelled that as GitHub's large-diff case, so an expired token and a 502 both raised "GitHub
omits the patch for very large diffs". Nothing wrote the settings_history_fetch_error key
check_style.py reads, so the report said "no data recorded" instead.

Change. GH.get_output_with_retries already owns the retry policy and still holds the exit
code and stderr where it gives up, so it gains an opt-in strict parameter that raises that
diagnostic instead of returning "". That diagnostic also put the unbounded out before err,
losing the cause once a caller bounds the message, so command, exit code and attempt count come
first now and out/err are capped individually. store_data.py calls it with strict=True,
keeps the large-diff message for a genuine null patch, adds a distinct one for rc=0-with-no-
output, and stores the bounded reason. It still does not raise, so the changed_files storage
other jobs depend on is unaffected.

Validation. 22 new tests drive the real helper against a fake gh on PATH, counting
invocations to tell a retry from a give-up, recording its argv to pin the issued command, and
calling the real check_settings_changes_history so the report is pinned against its own
producer. Every failure mode is compared against the pre-fix code, and 28 mutations confirm each
test is load-bearing.

Discharges item (3) of
#110395 (comment). Left for separate
PRs: Shell.get_output ignoring retries under strict=True, and the un-retried
master_commits fetch.

groeneai and others added 4 commits August 1, 2026 19:28
The Style check / settings_changes_history validator needs the diff of
src/Core/SettingsChangesHistory.cpp, which the store_data.py workflow hook
fetches from the GitHub API. When that fetch failed, the report never said why.

The fetch used Shell.get_output, which defaults to strict=False and makes a
single attempt: on a non-zero exit it prints stderr as a warning and returns
stdout anyway, i.e. an empty string. The following
`if patch.strip() in ("", "null")` then relabelled that empty string as
GitHub's large-diff case, so an expired token and a transient 502 both raised
"GitHub omits the patch for very large diffs". The except clause only printed,
and none of the hook's store_kv_data calls wrote the
settings_history_fetch_error key that check_style.py reads, so the report fell
back to "no data recorded by the store_data.py workflow hook". A single
transient 5xx was therefore fatal on a merge-blocking check instead of retried.

GH.get_output_with_retries already owns the retry policy and still holds the
exit code and stderr where it gives up, so it gains an opt-in strict parameter
that raises that diagnostic, now including the exit code, instead of returning
an empty string. This is the same shape as GH.get_changed_files(strict=False)
in the same file, which the hook calls one line above. store_data.py calls it
with strict=True, keeps the existing message for a genuine null patch, adds a
distinct message for rc=0 with no output, and stores the bounded reason under
settings_history_fetch_error. The hook still does not raise, so the
changed_files storage other merge-queue jobs depend on is unaffected. The fetch
moved to a module-level function because the block was __main__-guarded and so
unreachable from a test.

Worst-case retry cost is 4+8+16 = 28 s, paid only when the fetch is already
failing; the non-retryable classes still fail after one attempt.

The new parameter defaults to the previous behaviour: none of the existing call
sites passes a second positional argument, both existing test stubs accept
arbitrary keywords, and one of the new tests pins that default.

Two related problems are deliberately left for separate changes:
Shell.get_output ignores retries when strict=True, and the master_commits fetch
in this same hook is also un-retried.

Co-Authored-By: Claude Fable 5 <[email protected]>
The previous commit bounds the stored `settings_history_fetch_error` at 500 chars
because it lands on a public report page, but `GH.get_output_with_retries` built
its give-up diagnostic with the unbounded `out` field before `err`, and the
prefix is already 190 chars before `out:[` opens. `gh api --paginate` streams
each page as it arrives, so a 502 on the second page exits non-zero with the
first page's patch already on stdout. The 500-char window then filled with the
command and the patch text, and the stored message named neither the 502, the
exit code, nor the attempt count. That is worse than the behaviour this branch
replaced, where a definite but wrong reason at least appeared.

`GH.get_output_with_retries` now puts the fields that identify the failure -
command, exit code, attempt count - before the API-controlled output, and caps
`out` and `err` individually with an explicit elision marker. All 18 call sites
print this diagnostic and only one of them bounds it, so front-loading the cause
helps every caller and keeps one large response from burying the rest in a log.
`settings_history_fetch_error_message` keeps its own bound as a second line of
defence, and now elides the middle rather than the tail so a cause that happens
to sit last still survives.

Three test gaps that let this through are closed. The only test of the bound
asserted `len == 500` on a message whose informative text was at the front,
which head-, tail- and middle-truncation satisfy alike, and no cell drove the
fetch with a `gh` that both wrote large output and failed. The fake `gh` also
ignored its arguments, so the issued command was unconstrained: pointing the
fetch at another pull request left every test green. And nothing pinned the call
from `__main__`, so deleting it left every test green too. The fixture now
records its argv, the success paths assert the command targets the right pull
request and selects the right file, and the entrypoint wiring is asserted by
parsing the module rather than importing it, which would run the whole hook.

Co-Authored-By: Claude Fable 5 <[email protected]>
`GH.get_output_with_retries` reported `retry_count` in its give-up
diagnostic, but that counter is only incremented on the retryable path,
after the three non-retryable classes have already broken out of the
loop. A `Bad credentials`, `Validation Failed` or
`Resource not accessible` failure therefore reported
`after [0] attempts` next to `exit_code:[1]` and the stderr that prove
the command ran once, so the two halves of the same sentence
contradicted each other.

That field only reached a CI log before this branch. It now reaches a
public report page through `settings_history_fetch_error`, and the
preceding commit deliberately made it survive the message bound, so a
field that is wrong is worse than one that gets cut: on an expired
token, the likeliest real cause, it points a maintainer at the workflow
wiring instead of the credentials.

Count attempts where the subprocess is invoked and report that counter.
`retry_count` still drives the loop condition and the backoff delay, so
the retry policy is unchanged and exhaustion still reports
`MAX_RETRIES_GH`.

The existing non-retryable test asserted how many times `gh` ran but
never the count the message reports, which is why the two could
disagree unnoticed. Both are now asserted, for all three non-retryable
classes.
Two of the new tests could pass on code that had lost the property they exist to
protect.

`test_hook_stores_the_cause_so_the_style_check_reports_it` asserted against
`_style_check_report`, a local copy of `check_style.py`'s reporting branch, so a
change that stopped `check_settings_changes_history` surfacing the stored cause
would have left the whole file green while the report went back to the generic
`no data recorded` fallback. That end-to-end path is the point of the change, so
a cell now drives the real function: a failing fake `gh`, then
`store_settings_history_changes` to obtain the stored value, then the production
consumer. The copy is kept as a cheap local oracle, with its docstring corrected
to say so.

`test_get_output_with_retries_default_returns_empty_string` asserted only that a
non-strict failure returns `""`, which a mutant short-circuiting on
`not strict` also produces, having run nothing. The invocation count is now
asserted alongside the return value, so the retrying half of the contract the
other 14 callers depend on is actually pinned.

Two comments corrected. The `_FETCH_ERROR_MESSAGE_TAIL` note claimed the tail
window hedges against a cause that sits last; since
`GH.get_output_with_retries` orders `err` before `out`, that window belongs to
`out` whenever stdout is non-empty, so it is a hedge for arbitrary exception
texts rather than a guarantee for `err`. The note above the hook's call said
only setting names are stored, never the raw diff, which is now true of the
success key alone: the error key stores a separately bounded diagnostic that can
include a capped slice of `gh` output.

Comments and tests only. `store_data.py`'s syntax tree is unchanged, and
`check_style.py` and `ci/praktika/utils.py` are untouched.
@groeneai

groeneai commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (click to expand)

Four review rounds, each an independent cold read of the resulting code followed by a
second-model gate pass, adjudicated against the recorded evidence. Rounds 1-3 bounced with
blockers and majors; round 4 is clean and is what is published here.

# Round Finding Verdict
❌ 1 The bounded fetch-error message dropped the cause on this change's own headline carrier. gh api --paginate streams each page, so a 5xx on a later page exits non-zero with an earlier page's patch already on stdout; the diagnostic put the unbounded out before err, so the 500-char cap cut the 502, the exit reason and the attempt count. Reproduced with a real paginating gh mock: 1271 raw chars stored as 500, containing neither 502 nor err:[. AGREE, fixed. Diagnostic reordered to command / exit_code / attempts / err / out with each unbounded field capped individually, and the caller's head-truncation replaced by middle-elision with a visible marker.
❌ 1 The only bounding test asserted len == 500 and no newlines, which head-, tail- and middle-truncation satisfy alike, so no cell could see the finding above. AGREE, fixed. A sibling cell pins the property, and a cell drives the helper with a failing gh that also writes large stdout.
❌ 1 No cell pinned the issued command or the __main__ wiring: replacing the PR number in the fetch with 999999 left all tests passing, because the fake gh never inspected its argv. AGREE, fixed. The fake records argv and the cells assert repo, PR number, --paginate and the jq select; the wiring is pinned by parsing the module with ast rather than importing it.
❌ 2 The diagnostic reported the attempt count from the retry counter, which the three non-retryable classes leave at zero even though the command ran once, so an expired token reported exit_code:[1] after [0] attempts. That field is put on a public report page by this change, and made to survive the length bound by the round-1 fix, so a wrong value now misdirects a reader toward the CI wiring instead of the credentials. AGREE, fixed. A separate counter is incremented where the subprocess is invoked; the retry counter still drives the loop condition and the backoff ladder, so the retry policy and the exhaustion assertion are unchanged.
❌ 3 The end-to-end claim was asserted against a local copy of the style check's reporting branch, not the branch itself, so a change to the real consumer would have left the file green. AGREE, fixed. A cell now drives the real check_settings_changes_history. The prescribed acceptance mutation turned out to be a provably equivalent mutant (the hook writes exactly one of the two keys, so changed is None already fires on every failure state) and was replaced with two non-equivalent ones, which redden only the new cell and not the copy-based one.
❌ 3 The compatibility cell asserted only that a non-strict failure returns "", which a mutant that short-circuits and runs nothing also produces, so retrying could have been removed for the other callers with the file still green. AGREE, fixed. The invocation count is asserted alongside the return value.
⚠️ 3 The tail window of the bound cannot rescue a cause positioned last once out is large, so the comment claiming otherwise was inaccurate. AGREE on the comment, DISAGREE on redesigning the bound: measured, a real gh writes its status line first and every shipped failure cell keeps its cause, and every arrangement is strictly better than the pre-fix code, which lost all fields. The comment now states the measured property.
💡 4 monkeypatch.chdir in the new end-to-end cell is not load-bearing, since that kv shape returns before the version file is read. DISAGREE, kept: it mirrors the existing on-master sibling test and stops a future kv shape from silently depending on the pytest cwd.

Round 4 found no blocker and no major. Independently re-derived rather than accepted on
report: the mutation census (29 ids, 28 killed, 1 proven equivalent) recomputed from the
logs, with no test function left un-reddened; the blast radius by AST walk (15 production
call sites, 14 other than this fetch, none passing a second positional argument); the
diagnostic text matching none of the 40 CI failure patterns; do_command_with_retries,
get_changed_files, the history parser, check_style.py and utils.py all identical to the
base commit; and the message bound never exceeding its cap across the size boundary.

@groeneai

groeneai commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. A fake gh on PATH with a fixed exit code and stderr makes every failure mode deterministic; nothing is probabilistic. Both defects (the wrong cause, and the single attempt) reproduce 100% on the pre-fix code.
b Root cause explained? Yes. Shell.get_output defaults to strict=False and one attempt, so a non-zero exit returns an empty string; if patch.strip() in ("", "null") relabels that as GitHub's large-diff case; the except stores nothing, so check_style.py prints its generic fallback. Three causes collapse into one wrong message, and a transient 5xx is fatal.
c Fix matches root cause? Yes. The laundering is removed where it happens: GH.get_output_with_retries gains an opt-in strict that raises its existing diagnostic (plus the exit code) instead of returning "", and the missing writer is added. No message widening, no suppression, no guard at the failure site. The diagnostic's attempt count is corrected at the same time, because this pull request is what puts that field on a report page: it was reported from the retry counter, which the three non-retryable classes leave at zero even though the command ran once.
d Test intent preserved / new tests added? Yes. No existing test file is modified or weakened. 22 new tests in ci/tests/test_settings_history_fetch_error.py; the two correct pre-existing behaviours (the real large-diff message, and success) are pinned as preservation guards. Three of my own new oracles were strengthened during review, each because it could pass on code that had lost the property it existed to protect. First, the bounding cell asserted only that the stored message is 500 chars, which head-, tail- and middle-truncation satisfy alike; it is kept for the flattening and cap, with a sibling that pins the property instead. Second, the non-retryable cell asserted how many times gh ran but never the count the message reports, so the two could disagree unnoticed; both are now asserted, for all three classes. Third, the end-to-end cell asserted against a local copy of the style check's reporting branch rather than the branch itself, and the compatibility cell asserted only the return value of a non-strict failure, which a mutant that runs nothing also produces; a cell now drives the real check_settings_changes_history, and the invocation count is asserted alongside the return value.
e Both directions demonstrated? Yes, over 9 carriers. The control arm executes the pristine block's own shipped source lines, sliced out of the base file, so it cannot drift from master. Pre-fix: 401, 502, rc=0-empty and transient-502 all give the large-diff message, and the transient case fails outright. Post-fix: each names its own cause and the transient case succeeds on attempt 2. gh invocations are counted, so a retry is distinguishable from a give-up. The eighth carrier (a non-zero exit with a page of patch already on stdout, which gh api --paginate produces) is compared against this branch's own earlier commit rather than master, because the bounded message it exercises is introduced by this pull request and master would be a meaningless arm. The ninth carrier is the attempt count, compared the same way and for the same reason: on each of the three non-retryable classes the reported count goes from zero to one while the retryable class still reports three, so the retry policy is provably unchanged.
f Fix is general across code paths? Yes. Fixed in the shared helper that owns the retry policy rather than in this one consumer, so no retry logic is duplicated and both the exit code and the front-loaded, per-field-capped diagnostic reach all 15 production call sites, 14 of which do not bound the message themselves. All 10 invariant carriers were enumerated and dispositioned; do_command_with_retries and the hook's second un-retried fetch are deliberately and verifiably untouched (one concern per PR), including the same attempt-count inaccuracy in do_command_with_retries, whose message reaches no report page. The consumer side is pinned at the real function as well as at the helper, so the reported message cannot be validated only against a copy of the branch that produces it.
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes for the input space that exists here. The observable inputs are (exit code, stdout, stderr, PR number) and all boundaries are covered: rc=0 with a real patch / literal null / empty output; rc!=0 non-retryable / retryable / transient-then-success; PR number 0 and > 0; the merge-queue path where the number is 0 and the linked number is used; and, for the bound itself, a message under the cap, one over it with the cause first, and one over it with the cause last. Type wrappers do not apply: this is Python CI tooling, no ClickHouse data types are involved.
h Backward compatible? (maintainer-approved exception only) Yes, measured rather than assumed. The new parameter defaults to strict=False, so every existing caller's return contract is unchanged; an AST scan of all 15 production call sites finds none passing a second positional argument, and both existing test stubs accept **kwargs. The one change other callers see is the text of the diagnostic they print, which is deliberate; nothing parses it, verified by grepping for the literal and for its field markers. Two mutations pin the default now, one flipping it and one short-circuiting the non-strict path so nothing runs at all, which the return value alone could not see. The attempt-count correction touches only what the give-up message reports: the loop condition and the backoff ladder are unchanged, and a mutation that reports the old counter reddens four cells. No setting defaults, no serialization format, so nothing to record in SettingsChangesHistory.cpp.
i Invariants and contracts preserved? Yes. (1) The hook must never raise (raising breaks the changed_files storage other merge-queue jobs depend on) - the except still swallows, pinned by a test and by the mutation that removes it. (2) Fail-close on the reader side - every failure path still raises inside the helper, so one of the two keys is always written and the style check refuses to pass. (3) get_output_with_retries' postcondition for non-strict callers is unchanged; the raise is reachable only via the new opt-in. (4) The stored reason reaches a public report page, so it is flattened and length-bounded at the same 500 chars as before, but the elision moved to the middle with a visible marker so the bound can no longer swallow the cause; the token is passed to gh on stdin and cannot appear in its stderr, and the whole key-value bucket is base64-encoded by the runner. No concurrency or locking involved, and no early-return path bypasses the writer.

Session id: cron:clickhouse-impl-slot-6:20260802-003900

@groeneai

groeneai commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

cc @maxknv @leshikus, could you review this? The settings-history diff fetch used Shell.get_output, which returns stdout even on a non-zero exit, so an auth failure or a 502 became an empty string that the next check relabelled as GitHub's large-diff case, and the settings_history_fetch_error key check_style.py reads had no writer at all. It now goes through GH.get_output_with_retries with a new opt-in strict parameter that raises the retry helper's own diagnostic, so a transient 5xx is retried and a real failure reports its exit code and stderr.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Aug 2, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [eacc707]

Summary: ✅


AI Review

Summary

This PR makes the settings_changes_history workflow hook fail with the real GitHub error instead of laundering fetch failures into an empty diff, and it resolves the settings-history patch against the PR head file revision instead of the merged checkout. I did not find a remaining correctness or contract issue in the current head.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 2, 2026
@groeneai

groeneai commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 3174a5d

CI is fully finished on this head and there are no failures to own.

Check / test Reason Owner / fixing PR
(none) all 174 check-runs completed, 0 failures n/a
Sync - CH Inc sync (private, not actionable by me)

Finish Workflow and Config Workflow both succeeded. CIDB records 608 result rows across 7 checks
on this commit with 0 FAIL/ERROR, so the matrix genuinely ran rather than being skipped.

Session id: cron:our-pr-ci-monitor:20260802-020000

`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.
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Aug 3, 2026
Master rewrote the settings-history fetch this branch had extracted into
`fetch_settings_history_patch`, so the resolution is not a union: taking either side
whole would drop real behaviour.

Master's two changes are semantic and are preserved. `a7c28646f014464` reads
`src/Core/SettingsChangesHistory.cpp` at the PR head instead of the CI checkout,
because the patch's new-file line numbers refer to the head file and the checkout is
the PR merged with its base, so a base branch that grew an earlier
`addSettingsChanges` block shifts every line below it and the parser attributes added
entries to the wrong block, even the wrong namespace. `aa4d71aa820b971` takes
`.patch` and `.contents_url` from the same `pulls/N/files` entry so both halves come
from one pinned revision even if the PR is updated in between.

This branch's changes are preserved too. The extracted helper is renamed
`fetch_settings_history_patch_and_file` and now returns the pair, both reads go
through `GH.get_output_with_retries(strict=True)` so a transient 5xx is retried and a
command failure raises naming the real cause, and `store_settings_history_changes`
writes that cause to `settings_history_fetch_error`, the key `check_style.py` reads
and which still has no writer on master.

Master's own mislabelling moved rather than disappeared: with the second read added
and no `strict`, a 5xx on the contents read returned an empty string that the
emptiness check reported as "no content returned". Both reads are strict, so each
failure mode keeps its own message.

Every `ast.dump` of the five symbols master and this branch share is identical, so
master's parser is taken whole and no master symbol is dropped. Verified: the two
master fixes reproduced through the production entrypoint with a negative control
that shows a checkout-resolving hook reports the wrong namespace; the pinned
`contents_url` is the one read; 28 cells in this PR's suite and 53 across all three
settings-history modules pass; seven mutants, one per preserved behaviour, each
redden; full `ci/tests` shows no failure absent from a pristine `origin/master`
control; `ruff check ci/` clean; no submodule pin drift.
The entrypoint oracle collected the guard's condition text and asserted substrings, so it
accepted a guard that can never run: appending `and False` to the condition, or nesting the
call under `if False:`, keeps both expected substrings while the hook stores neither the
changed settings nor the fetch error in CI. Both mutants were measured green.

The guarding statements are now extracted and EXECUTED against a fake `Info` and an
injected call recorder, parametrized over four cases so the guard has to be load-bearing in
both directions: a PR touching the file and a merge-queue run reach the hook, while a PR
touching another file and a non-PR non-queue run do not. A hook that always ran fails the
latter two rather than passing for the wrong reason.

The walk starts at the `__main__` block's body rather than the block itself, because the
`__name__ == '__main__'` test is a guard too and executing it would be false under pytest
and never reach the guard under scrutiny.

Measured: five mutants now redden, including the two the previous oracle let through and
one dropping `is_merge_queue_event`; the three preserved-behaviour mutants from the merge
still redden; 31 cells here and 56 across all three settings-history modules pass; full
`ci/tests` shows no failure absent from a pristine `origin/master` control.
@groeneai

groeneai commented Aug 6, 2026 •

Copy link
Copy Markdown
Collaborator Author

While resolving this PR against master I also measured a residual in the settings-history diff
parser that I am not raising, and I want to record why rather than leave it implied.

parse_settings_history_changes returns [] when a whole addSettingsChanges block that has no
surviving block above it is deleted, because removals are resolved against the post-change file
(store_data.py:179) and the header fallback scans backwards (:230) and finds nothing above the
first block; check_style.py:682 then treats an empty list as "nothing to validate" and passes.
Measured on real git diffs of the real file against current master: deleting the first block
(26.8, SettingsChangesHistory.cpp:44) gives n=0, while deleting a later block (26.6) gives
n=97 and deleting a single entry gives n=1, so the escape is confined to the first block.

It is not a fix I think is worth making, for three measured reasons:

  • 03999_stateless_settings_history already catches it. Simulating the 26.8 block's absence,
    its "new setting neither in the frozen snapshot nor documented" arm
    (03999_stateless_settings_history.sh:104) reports 18 violations against 0 on pristine
    master, and the reference file is empty, so the test fails. Of the 4 remaining names 3 record
    previous_value == new_value == the frozen baseline, so deleting the row loses nothing, and the
    4th (max_insert_threads) is only invisible today because of that test's own auto(%)
    exclusion at :138: a revert would make its default disagree with the baseline and fire.
  • master's first block is always the unreleased version (master is 26.8, newest stable is
    26.7.2.59), and compatibility only replays rows newer than the requested version, so
    deleting a row for a change reverted before it ships is the correct action. Misattributing a
    shipped release needs a shipped block, which is always a later block, where the fallback already
    fail-closes. The parser does not exist on any release branch (26.7, 26.6, 26.3, 25.8 all
    return 0 matches for parse_settings_history_changes).
  • It has never happened. Of the 5073 commits touching SettingsChangesHistory.cpp since
    2024-08, ten remove an addSettingsChanges header: eight are header edits that re-add one, and
    the two genuine net block removals are both correctly reported by the current parser, because
    neither is a first-block deletion. 6d77695c removes the 26.6 Session block, which was the
    second Session block at the time, and is reported as n=3; 3b3bd59c removes an empty
    merge_tree_settings_changes_history 26.6 block that had a Session block above it, and is
    reported as n=1. (Corrected: an earlier revision of this comment said three and one. I read a
    still-running census; the completed run found ten and two. The conclusion is unchanged, and the
    extra commit is a second measured instance of the fallback working as designed.)

The comment at store_data.py:221-227 already states that the whole-block case fail-closes on
the block above by design, so this is that design's one position with nothing above it rather than
an unnoticed hole. Recording it here for whoever touches this parser next; no follow-up from me.

@maxknv
maxknv self-requested a review August 6, 2026 09:38
@maxknv

maxknv commented Aug 6, 2026

Copy link
Copy Markdown
Member

@groeneai fix conflicts

Master's `b5a7e34ccf42820` (recognize a renamed settings-history record) added
`_settings_history_entry_without_name` at the same anchor where this branch
extracts the fetch helpers out of the `__main__` block, so both sides add new
top-level definitions in one place.

Resolved as a UNION: the two sides are disjoint. Master rewrote
`parse_settings_history_changes` and this branch never touched it; this branch
rewrote the `__main__` block and master never touched it. Proven by AST rather
than by reading - a per-symbol `ast.dump` index of the three merge stages and of
the resolution gives 17 symbols, exactly the union of the 16 on this branch and
the 11 on master, with 0 missing, 0 extra and every symbol byte-identical to one
side or to both. `parse_settings_history_changes` is `ast.dump`-identical to
master's; the `__main__` block is `ast.dump`-identical to this branch's.

Master's rename recognition was re-probed through the merged parser, with a
discriminating negative control: a pure rename inside one block reports the new
name only, while the same pair whose reason text differs still reports both, so
the probe can tell the two apart rather than passing vacuously. This branch's own
behaviour was re-probed the same way: a 502 on the fetch is recorded under
`settings_history_fetch_error` with the real cause, and the success path still
records `settings_history_changed_settings` and no error key.
The comment above the hook claimed only the setting names are stored, never the
raw diff. That is true of the success path, but the failure path stores the
exception from `GH.get_output_with_retries`, whose message ends in an `out:[...]`
field capped at 300 characters, and for a failed `--paginate` read of the file
list that output is patch text.

Measured through the production helper with a 16 kB synthetic patch as the API
output: the stored value is 500 characters and about 200 of them are that patch
text, so the old wording was wrong about what can appear there.

Comment only - the bound itself is unchanged and deliberately not widened. What
the comment protects still holds: `runner.py:718` base64-encodes the whole
`JOB_KV_DATA` bucket before it becomes a pipeline output, so nothing here can
match a secret pattern in the clear, and the key stays bounded.
@groeneai

groeneai commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

@maxknv done, the PR is MERGEABLE again as of eacc707e5d3885f.

One conflicted file, ci/jobs/scripts/workflow_hooks/store_data.py, one hunk. Your
b5a7e34ccf42820 (recognize a renamed record) adds _settings_history_entry_without_name at the
same anchor where this branch lifts the fetch logic out of the __main__ block, so both sides add
new top-level definitions in one place. The two changes are disjoint: you rewrote
parse_settings_history_changes and I never touched it, I rewrote the __main__ block and you
never touched it. So I took the union, and checked it by AST rather than by reading, because a
mangled function body passes a visual review. A per-symbol ast.dump index of the three merge
stages and of the resolution gives 17 symbols, exactly the union of my 16 and master's 11: 0
missing, 0 extra, every symbol identical to one side or to both, and
parse_settings_history_changes identical to yours.

Your rename recognition re-probed through the merged parser, with a control that discriminates: a
pure rename inside one block reports the new name only, while the same pair whose reason text
differs still reports both names. Mine likewise: a 502 on the fetch is recorded under
settings_history_fetch_error with the real cause, and the success path still records
settings_history_changed_settings and no error key.

The three settings-history suites are 62/62, including your test_settings_history_diff_parser.py
and test_settings_history_source_gate.py. Full ci/tests: 5 failed / 676 passed here against 5
failed / 645 passed on a pristine origin/master checkout, identical failure sets, so 0 new
failures (those 3 modules are blob-identical to master and want a live server on this host).
ruff check ci/ clean.

One extra commit beyond the merge. The comment above the hook said only the setting names are
stored and never the raw diff. True of the success path, but the failure key carries the gh
diagnostic, whose out:[...] field is capped at 300 characters and for a failed --paginate read
is patch text, of which roughly 170 characters survive into the stored value. Comment only, the bound is
unchanged, and runner.py:718 base64-encodes the whole JOB_KV_DATA bucket so nothing there is
exposed in the clear.

@maxknv
maxknv enabled auto-merge August 7, 2026 11:27
@maxknv
maxknv added this pull request to the merge queue Aug 7, 2026
Merged via the queue into ClickHouse:master with commit a68c6d5 Aug 7, 2026
180 checks passed
@groeneai

groeneai commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - eacc707

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Build (arm_release) / Post Hooks infra, not PR-caused. The build_profile_hook.py telemetry INSERT into build_time_trace is rejected by the CI logs cluster. Non-gating: the enclosing Build (arm_release) check-run concluded success, and the hook uploads build-profile telemetry only. a fix task is moved to pending (investigating at full effort - fixing-PR link to follow on this PR)
Sync - CH Inc sync (private, not actionable by me)

All 176 check-runs completed with 0 queued or in_progress (7 success, 169 skipped, 0 failing
check-run); Config Workflow and Finish Workflow both success. Post Hooks is a hook-level
pseudo-test rather than a check-run of its own, which is why the check-run census shows no failure
while the row above still needs an owner.

Fix presence was established per build. #113409 ("Retry the build-profile telemetry INSERT through
the CI logs cluster memory-pressure spikes") merged 2026-08-06T00:05:00Z as de947727b2ba, and
gh api compare/de947727b2ba...eacc707e5d38 reports status=ahead, behind_by=0, i.e. the merge
commit is an ancestor of this head, so the retry fix IS present and the INSERT still failed. Per the
per-build rule that means #113409 must NOT be linked as the owner here, and the residual belongs to
the fix task above. Controls for the same probe: current master also behind_by=0, and a separate
head independently measured as post-fix reads behind_by=0 too.

This supersedes the earlier ledger on 3174a5de4b6165937a24e59736b3f097aa6e7dcd, which is no longer
this PR's head.

Session id: cron:our-pr-ci-monitor:20260807-130000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors manual approve Manual approve required to run CI pr-ci 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.

4 participants