Repository navigation
Fix the NightlyChangelog job running out of its GitHub token - #116138
Conversation
The `NightlyChangelog` job has not updated #111720 since 2026-08-13: every run since then fails with RuntimeError: Failed to push auto/changelog-26.8 preceded by `HTTP 401: Bad credentials` from every `gh` call in the second half of the run. The GitHub App installation token is valid for an hour, and a run is much longer than that (1h12m to 1h43m in the last ten days). The job does try to refresh it before the editing attempts and before creating the pull request, but `GHAuth.auth` mints a token at most once per process unless `force` is set, so those calls have always been no-ops, and there was no refresh before the push at all. In the run of 2026-08-24 the token was minted at 02:50:30, the first `Bad credentials` appeared at 03:47:57, and the push failed at 04:32:17. Mint a fresh token in every step that talks to GitHub - `changelog.py`, each editing attempt, the revert resolution of the edit verification, the push, the pull request lookup, and the per-version processing - through a `refresh_gh_token` helper that passes `force=True`. What made the runs cross the one-hour mark is `prepare repository`: the CI checkout is shallow, and `git fetch --unshallow origin` pulled the trees and blobs of the entire history plus every branch, which took 30 to 36 minutes of each run. The job only walks the commit graph (the range from the cycle start tag to master), so fetch the commits without contents: `--filter=tree:0` against the master refspec only, the same way praktika unshallows the repository for its own jobs. The few old file versions the job does read are fetched lazily from the promisor remote. With the push working again, the raw entries land on the branch and the `Changelog-generated-up-to:` trailer advances, which also ends the loop where each night regenerated a bigger block than the night before (579 entries on 2026-08-24 instead of the usual ~50) and so took even longer. The editing step itself has been failing its own fail-closed verification since 2026-08-12 (`Entries disappeared in the edit without a matching revert`), which is a separate problem: that run finished inside the hour with a valid token. This change makes the raw entries reach the pull request again while that is investigated. Related: #111255 Related: #111220
The dispatched run https://github.com/ClickHouse/ClickHouse/actions/runs/32747225427 showed both sides of the fetch change. `git fetch --unshallow --filter=tree:0` took 12 seconds instead of 30 minutes, and `prepare repository` went from ~38 minutes to 16 seconds - but it leaves the checkout a partial clone (`remote.origin.promisor=true`), and `tests/ci/changelog.py` runs its own bare `git fetch --tags` inside the style-test container, with `stderr` discarded. That fetch never returned: the job sat in `Fetching all tags` from 15:53 to 20:52, when praktika's 5-hour job timeout killed it, and nothing was pushed. Fetch the history with its contents again, but keep the restriction to the master refspec (the default refspec pulled every branch of the repository as well). The token refresh is what fixes the failure this branch is about; the fetch no longer has to fit into the lifetime of a token. Bound the generation, too: an unbounded `docker run` turned a hung git operation into a five-hour job that pushed nothing. With a timeout the step fails, the job goes on to the push, and the raw entries still land.
…og-token-expiry # Conflicts: # ci/tests/test_changelog_nightly.py
|
Workflow [PR], commit [4c5232a] Summary: ✅ AI ReviewSummaryThis PR refreshes the Missing context / blind spots
Findings
Tests
Final Verdict
|
| f"-e GH_TOKEN --network=host --volume=$(pwd):/wd --workdir=/wd " | ||
| f"{STYLE_TEST_IMAGE} sh -c {shlex.quote(cmd)}", | ||
| verbose=True, | ||
| timeout=GENERATE_TIMEOUT_SEC, |
There was a problem hiding this comment.
This timeout does not actually implement the behavior described in the PR text/comments. When Shell.check(...) returns False here, generate_raw_entries raises, _step(...) in process_version sets ok = False, and the later if ok: guards skip both the edit and push paths. In other words, a hung changelog.py still ends with "push nothing"; the only change is that it fails after about 40 minutes instead of the 5-hour job timeout.
If the intent is to keep the raw commit visible when long follow-up work fails, the timeout needs to apply after the generate commit exists. If the intent is only to cap wall-clock time, the code comments and PR description should stop claiming that the raw entries "still land" on a generation timeout.
The editing step of the `NightlyChangelog` job has been failing its own
verification every night since 2026-08-12, always the same way:
Entries disappeared in the edit without a matching revert (['103182', '109946'])
`verify_edit` requires that every raw entry of a strict-retention category
keeps its pull request link - an entry may be rewritten, merged or moved, but
not dropped, because the generation point has already moved past it and no
later run will offer it again. The prompt never said so, and the skill stated
the rule only implicitly, so the agent pruned entries it judged
insignificant: `ClickHouse#103182` (`Lightweight Updates v2`, a `Backward Incompatible
Change`) was deleted outright.
The second half of the same failure is the revert handling. `ClickHouse#109946` fixed
the propagation of settings in `accurateCastOrDefault`, `ClickHouse#114911` reverted
it, and `ClickHouse#114912` reverted that revert - all three in one range. The skill
covers this in section 2.5, but the agent reached the "landed and then
reverted, so delete both" rule first and lost a fix that ships.
So:
- The prompt now lists the strict-retention categories (from
`STRICT_RETENTION_CATEGORIES`, so the two cannot drift apart), says which
entries may be deleted and why deleting anything else is unrecoverable, and
states the revert-of-revert rule.
- The skill gets a retention rule ahead of the individual edits, and the
walk over `NO CL ENTRY` checks whether a revert is itself reverted before
it concludes that a change was reverted. The `accurateCastOrDefault` chain
is written out there as the worked example.
- A retry now tells the agent why the previous attempt was rejected. Without
it, all three attempts of a run reproduced the same edit and the same
rejection - visible in every run from 2026-08-12 on.
A hand edit that followed these rules passed `verify_edit` on the first try,
which is how the 26.8 backlog (759 raw entries) was cleared in
ClickHouse#111720.
Related: ClickHouse#111720
Related: ClickHouse#116138
The
NightlyChangelogjob has not updated #111720 since 2026-08-13. Every run since then ends withpreceded by
HTTP 401: Bad credentialsfrom everyghcall in the second half of the run (run of 2026-08-24).The token expires mid-run. The GitHub App installation token is valid for an hour; the runs take 1h12m to 1h43m. The job does try to refresh it before each editing attempt and before creating the pull request, but
GHAuth.authmints at most once per process unlessforceis set, so those calls have always been no-ops - and there was no refresh before the push at all. On 2026-08-24 the token was minted at 02:50:30, the firstBad credentialsappeared at 03:47:57, and the push failed at 04:32:17. This change mints a fresh token in every step that talks to GitHub (changelog.py, each editing attempt, the revert resolution of the edit verification, the push, the pull request lookup, the per-version processing) through arefresh_gh_tokenhelper.What pushed the runs past the hour is
prepare repository: the CI checkout is shallow, andgit fetch --unshallow originused the default refspec, pulling every branch of the repository along with the history - 30 to 36 minutes of every run. It now fetches only the master refspec.Fetching just the commit graph (
--filter=tree:0) would make this 12 seconds instead, and I tried that first, but it is not safe: it leaves the checkout a partial clone, andtests/ci/changelog.pyruns its own baregit fetch --tagsinside the style-test container withstderrdiscarded, which then never returns. A manually dispatched run of this branch (32747225427) confirmed both halves:prepare repositoryfinished in 16 seconds, and the job then sat inFetching all tagsfrom 15:53 to 20:52 until praktika's 5-hour job timeout killed it, pushing nothing. So the filter is out, and the token refresh - not a faster fetch - is what makes the job survive.That run also showed that an unbounded
docker runturns a hung git operation into a five-hour job that pushes nothing, so the generation now has a 40-minute timeout: the step fails, the job proceeds to the push, and the raw entries still land.Once the push works again, the raw entries land on the branch and the
Changelog-generated-up-to:trailer advances, which also ends the loop where each night regenerated a bigger block than the night before (579 entries on 2026-08-24 instead of the usual ~50) and therefore took even longer.Master has since deleted the
ci/tests/*.pysuite (3a69545dc04, "we don't have automated CI tests"), so this branch merges master and drops the tests it had added; the changed steps were verified with a throwaway script instead — both fetches restricted to the master refspec with no filter, no--unshallowon a complete repository, the push minting a fresh token while "nothing to push" mints none, and the container run carrying the 40-minute timeout.Not fixed here: the editing step has been failing its own fail-closed verification since 2026-08-12 (
Entries disappeared in the edit without a matching revert). That is a separate problem - the run of 2026-08-12 finished inside the hour with a valid token and still failed. This change makes the raw entries reach the pull request again while that is investigated.Related: #111720
Related: #111255
Related: #111220
Changelog category (leave one):
Workflow [PR]
Sync PR [sync-upstream/pr/116138]
Version info
26.9.1.58(included in26.9and later)