Skip to content

Compare a cold commit range in stages when GitHub answers 422 - #5012

Merged
Mpdreamz merged 4 commits into
mainfrom
fix/compare-cold-range-retry
Nov 23, 2026
Merged

Mpdreamz merged 4 commits into
mainfrom
fix/compare-cold-range-retry

Conversation

@Mpdreamz

@Mpdreamz Mpdreamz commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Bundling a large repository no longer fails when GitHub has not computed the commit range yet: the range service compares it in stages and asks again.

Affects: Release notes

Why

The compare API answers 422 "Sorry, this diff is taking too long to generate" for a range of elastic/cloud that GitHub has not computed. The same request succeeds once GitHub has. A first run, such as the first preview build of the Elastic Cloud Hosted release notes (290 commits), fails with GitHub compare request ... failed: 422, and a rerun passes.

What

Staged warm-up

When the first compare page answers 422 because GitHub is still computing the range, the service resolves the start to a commit (a tag or branch is fine), lists the commits of the range (at most ten pages) and compares the start with every 50th commit, oldest first. Each stage builds on the one before, so the comparison of the whole range is cheap. A stage that is not ready waits and retries up to three times, with no wait after the last attempt, and a failed stage is skipped. A 422 for another reason, or a failed request of the warm-up itself, does not stop the request for the whole range.

Whole range, once more

After the stages, the service asks for the whole range one more time. A range that still answers 422 reports the same error as before, so a persistent failure does not loop. A start that is not among the newest 1,000 commits of the end gets the single retry without stages.

Verify

dotnet test --project tests/Elastic.Changelog.Tests --treenode-filter "/*/*/GitHubCommitRangeServiceTests/*"

I checked the cause live: the call that failed returned 290 commits on repeat, and every staged comparison of the same range succeeded. The staged path itself runs against a fake handler only. Disabling the 422 branch fails three tests.

For a large repository such as elastic/cloud, GitHub answers 422 "taking too long to generate" for a range it has not computed yet, and answers the same request once it has. The range service now lists the commits of the range, compares the start with every 50th one in order, and asks for the whole range again. A range that stays unprocessable is still an error.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

The warm-up now starts only when GitHub says it is still computing the range, not for any 422. It resolves a tag or branch start to a commit before looking for it, skips the wait after the last attempt of a stage, and no longer lets a failed request of its own stop the request for the whole range.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
A full commit sha is no longer looked up, and an unusable or failed lookup of a tag now leaves the start as written instead of stopping the stages or the build. Tests cover the cap of ten history pages.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
When the lookup of a tag or branch fails, the start is not a sha, so the staged compare no longer reads ten history pages to look for it. A test with an abbreviated sha and a failing lookup shows the stages still run.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
var startSha = await ResolveCommitShaAsync(args, args.StartRef, ctx).ConfigureAwait(false);

// A ref that is still a name, such as a tag whose lookup failed, matches no commit, so reading the history would only delay the retry.
if (!CommitShaRegex().IsMatch(startSha))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity: P3 (Low)

This guard skips warm-up for six-character start SHAs, even though the CLI docs show --start-git-ref abc123. If the ref lookup fails, a unique six-character prefix could still match the start in the commit history, but the guard returns before looking. The final compare then retries the cold range without any stages and can still fail with 422. Preserve fallback matching for short SHA prefixes while skipping non-hex ref names.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True: CommitShaRegex is 7 to 40 characters, so a six-character prefix is not treated as a sha after a failed lookup. The warm-up is best effort, and the whole range is still asked for again, so the cost is a missed warm-up in a rare case. Leaving it.

@Mpdreamz
Mpdreamz merged commit bcc5772 into main Nov 23, 2026
44 checks passed
@Mpdreamz
Mpdreamz deleted the fix/compare-cold-range-retry branch November 23, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant