fix: store the FULL open-PR set in Status.SourceBranches, not just the delta - #1
Merged
Merged
Conversation
…e delta
Reconcile stored `pullrequest.Status.SourceBranches.Branches = setDifferences`
— only the branches newly added since the last poll — into the authoritative
open-PR set that the downstream pipeline-trigger-operator reads. So:
- PR opened → SourceBranches truncated to the 1 new PR
- PR closed → setDifferences empty → SourceBranches blanked entirely
Either way the consumer saw a truncated branch set and rebuilt every open PR
(~188 PipelineRuns) with no new commits, and the next poll re-diffed against
the truncated state → endless "New PR received" churn (incident 2026-07-06).
Fix: store the full polled list while still emitting events only for the
genuinely-new PRs. Extracted the store-decision into a pure helper
`nextSourceBranches(current, polled)` returning (fullList, newlyAdded), and
added a unit test that drives it across initial/add/remove polls and asserts
the full list is always retained. The test fails against the old delta-only
code (add stores {c}, remove stores {}).
Orthogonal to the label-retrigger customization: newBranches already carries
the label-folded commit discriminators, so a label change still appears as a
new entry and still retriggers.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem (production incident 2026-07-06)
Reconcilepolls GitHub for the current open-PR set (newBranches, the FULL list) and then stored only the delta into the authoritative state the downstreampipeline-trigger-operatorreads:Status.SourceBranchesis supposed to be the complete set of open PRs. Storing onlysetDifferencestruncates it:SourceBranchesbecomes a partial list of 1.setDifferencesis empty →SourceBranchesbecomes empty.Either way the consumer sees a truncated branch set and rebuilds every open PR (~188 PipelineRuns) despite no new commits, and the next poll re-diffs against the truncated state → endless "New PR received" churn. This is the producer half of the incident; the consumer-side guard already shipped.
Fix
Store the FULL current list while still emitting
New PR ... receivedevents only for the genuinely-new PRs. The store-decision is extracted into a tiny pure helper:Orthogonal to this branch's label-retrigger customization:
newBranchesalready carries the label-folded commit discriminators from the poller, so a label change still shows up as a new entry and still retriggers. No other logic changed.Test
controllers/pullrequest_controller_helpers_test.go→TestNextSourceBranchesdrives the helper the wayReconciledoes across successive polls (initial population → add → remove) and assertsSourceBranchesalways equals the FULL polled list while events fire only for genuinely-new PRs.Verified both directions:
{c}(want{a,b,c}), remove case stores{}(want{a,b}).go build ./...andgo test ./pkg/... ./api/... ./controllers/...are green. The pre-existingcontrollers/suite_test.goGinkgo/envtest suite (TestAPIs) has no specs, so it passes trivially without envtest binaries. CI (.github/workflows/test.yml) gains a targetedgo test ./controllers/... -run TestNextSourceBranchesstep (the full envtest suite is still excluded, as before).mainandgh-conditional-requestscarry the identical upstream bug (= setDifferences). This PR only fixes the deployed civitai branchfeat/label-retrigger; those branches are not touched here.🤖 Generated with Claude Code