Repository navigation
Fix praktika is_merge_queue_event comparing the event type against GitHub's event name - #112227
Conversation
…'s event name _Environment.EVENT_TYPE only ever holds a Workflow.Event value, and Workflow.Event.MERGE_QUEUE is "merge_queue". "merge_group" is GitHub's event NAME, which _environment.py correctly keys on when reading the webhook payload before storing the enum value. Info.is_merge_queue_event compared EVENT_TYPE against that event name, so it was never true in a real merge-queue run and every consumer silently took the pull-request branch. The visible symptom was a deterministic Style check / settings_changes_history red in the merge queue for PRs touching src/Core/SettingsChangesHistory.cpp: store_data.py computes strict=bool(info.pr_number) or info.is_merge_queue_event (False in the queue, where pr_number is 0) and gates its settings-history block on the same predicate, so settings_history_changed_settings was never stored and check_style.py fail-closed with "no data recorded by the store_data.py workflow hook". The check was correct; the hook skipped half its work. All 5 merge-queue failures in the last 10 days are exactly the merge-queue entries that touched that file, while all 39 passing merge-queue runs took the "path not in changed_files" early return, so the validator had never validated anything there. Compare against the enum constant rather than swapping in the "merge_queue" literal, so the value and GitHub's event name cannot drift apart again. Five consumers besides the settings-history gate start working: get_changed_files regains its fail-closed path instead of the 300-entry-capped commits API, and the merge-queue flaky check picks up its intended 20 reruns / 20 minute budget instead of the 50 / 45 minute PR values. The sibling is_push_event and is_dispatch_event predicates compare literals that equal their enum values, so they were never broken and are left alone. The new test drives a real merge_group payload through _Environment.from_env() into the real Info property, asserting the whole event matrix and the linked PR number parsed from the queue head ref. It deliberately does not mock the predicate: the merge-queue tests in ci/tests/test_gh.py build a SimpleNamespace with is_merge_queue_event=True, which is why they could not catch this. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Internal second-model review (click to expand)Two independent review passes over this diff before it was opened: a cold read by a reviewer that Result: 0 blockers, 0 majors. 3 nits, all in this PR's description, all fixed before opening.
Checks the cold pass ran independently rather than taking on trust:
Session id: cron:clickhouse-review-slot-49:20260728-054501 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20260728-051600 |
|
cc @maxknv — could you review this? |
|
Workflow [PR], commit [9ef8826] Summary: ✅ AI ReviewSummaryThis PR fixes Final Verdict
|
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Info.is_merge_queue_eventcompared_Environment.EVENT_TYPEagainst"merge_group", butEVENT_TYPEonly ever holds aWorkflow.Eventvalue, andWorkflow.Event.MERGE_QUEUEis"merge_queue".merge_groupis GitHub's event name;merge_queueis praktika's enum value.So the predicate was never true in a real merge-queue run, and every consumer silently took the
pull-request branch. Fixed by comparing against the enum constant, so the two cannot drift again.
How it surfaced:
Style check/settings_changes_historyfails deterministically in the mergequeue for any PR that touches
src/Core/SettingsChangesHistory.cpp, withReport:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=gh-readonly-queue/master/pr-110395-4a44dcefc451d3da3f7a9e7c8a38f74180b34ebc&sha=999b2e18000966dd17c2060fb5c0e83f955bfb11&name_0=MergeQueueCI&name_1=Style%20check
store_data.py's__main__computesstrict=bool(info.pr_number) or info.is_merge_queue_event,which is
Falsein the queue (pr_numberis 0 there), and gates the settings-history block on(info.pr_number or info.is_merge_queue_event) and settings_history_file in changed_files, alsoFalse, sosettings_history_changed_settingsis never stored.check_style.py'scheck_settings_changes_historythen sees the file inchanged_fileswith no recorded data andfail-closes. The check is behaving correctly; the hook silently skipped half its work. The failing
job's own environment dump confirms
EVENT_TYPE='merge_queue',PR_NUMBER=0,LINKED_PR_NUMBER=110395, and that the stored kv keys are exactly['changed_files', 'build_digest', 'master_commits'].CIDB,
test_name = 'settings_changes_history', last 10 days as of 2026-07-28 06:37 UTC:head_ref LIKE 'gh-readonly-queue/%')The 5 merge-queue failures are exactly the merge-queue entries that touched the file (2 PRs), i.e.
100% on qualifying entries. The 40 passing merge-queue rows span 36 distinct PRs and none of those
36 touches the file, so every one of them took the
path not in changed_filesearly return: thevalidator has never actually validated anything in a merge queue. The PR workflow is unaffected.
Consumers that were on the wrong branch and now work:
GH.get_changed_filesis called withstrict=True, i.e. fail-closed changed-file detection.linked_pr_number.GH.get_changed_filesitself queriespulls/<linked>/files --paginateinstead of the300-entry-capped
commits/<sha>API, regaining the fail-closed guarantee its own comment existsfor. For the Parallelize the final merge of single-level aggregation hash tables #110395 queue entry both endpoints return the same 17 files, so nothing changes on a
small PR while the cap disappears on a large one.
functional_tests.pymerge-queue flakyrerun_count50 -> 20.functional_tests.pyFLAKY_CHECK_TIME_LIMIT45 min -> 20 min.The sibling predicates
is_push_eventandis_dispatch_eventcompare literals that happen toequal their enum values (
"push","dispatch"), so they were never broken; converting them to theenum form is behaviour-neutral hygiene and is out of scope here. The new test pins those two
equalities, so a later rename of
Workflow.Eventfails a test instead of silently repeating thisbug.
_environment.py'selif "merge_group" in github_event:is correct as written - that onelegitimately reads the GitHub payload before storing the enum value - and is unchanged.
Behaviour changes worth calling out:
newly-enforced reds on queued PRs that add or change a setting without an entry under the
current version block. That is the intended behaviour of the check.
GH.get_changed_files's fail-closedraisebecomes reachable inside a pre-hook. If amerge-queue head ref ever yields no linked PR number,
store_data.pynow raises where itpreviously fell through;
native_jobs.pywraps each pre-hook in aPre Hooksresult whosenon-OK status gates the rest of the config job, so that surfaces as a loud failure rather than a
hang or a silent skip. In practice it should not fire: all 6510 distinct merge-queue head refs
in the last 180 days match the canonical
gh-readonly-queue/<base>/pr-<N>-<sha>shape and noneis unparseable.
introduced it.
Test:
ci/tests/test_info_event_type.pydrives a real GitHubmerge_grouppayload through_Environment.from_env()into the realInfoproperty and asserts the full event matrix(
merge_group-> True;pull_request,push,schedule,dispatch-> False), plus that thequeue head ref yields
linked_pr_number == 110395. It deliberately does not mock the predicate:the existing merge-queue tests in
ci/tests/test_gh.pybuild aSimpleNamespacewithis_merge_queue_event=True, which is why they could not catch this. Reverting the one-line changemakes the new test fail on exactly that assertion.
Separately,
check_style.pyreads asettings_history_fetch_errorkey that nothing ever writes, soa genuine diff-fetch failure reports the generic "no data recorded" text instead of its real cause.
That is a distinct root cause (the fetch goes through
Shell.get_output, which returns stdout evenon a nonzero exit, so simply storing the exception would record a mislabelled reason) and is being
fixed separately rather than folded in here.
Version info
26.8.1.254(included in26.8and later)