fix: CORE4-labelling check - get labels by GitHub API, not event payload - #111
Merged
Merged
Conversation
rtyley
added a commit
to guardian/play-secret-rotation
that referenced
this pull request
Dec 30, 2025
rtyley
force-pushed
the
core4-get-labels-by-github-api
branch
from
December 30, 2025 14:23
bbde411 to
75c4ec3
Compare
rtyley
marked this pull request as ready for review
December 30, 2025 17:21
rtyley
force-pushed
the
core4-get-labels-by-github-api
branch
from
December 31, 2025 10:34
75c4ec3 to
0d27aef
Compare
tjsilver
added a commit
to guardian/actions-static-site
that referenced
this pull request
Jan 5, 2026
tjsilver
approved these changes
Jan 5, 2026
tjsilver
left a comment
Contributor
There was a problem hiding this comment.
Looks good. I tested it on the workflow in the PR on actions-static-site (now reverted) and the workflow ran as before (run here). (It did fail due to a permissions error on test-repocop-prs which threw me off a bit at first.) I also tested it on the existing workflow in service-catalogue here. We would need to manually release a new version after this change is merged.
Member
Author
Thanks @tjsilver ! Is the release process in this repo as simple as adding a new tag and marking it as a GitHub release? I guess for this particular PR it feels like just a 'point' upgrade, ie v2.0.1 after the current v2.0.0 ? |
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.
This change fixes a race-condition that very occasionally causes the CORE4 check to fail on a PR with valid labelling, and continue to fail even if it is re-attempted with multiple job invocations afterwards.
Background
CORE4-labelling check
The CORE4-labelling check was created with PR #105, and updated a little later with PR #108 to accept
dependenciesas a valid label - because both Dependabot & Scala Steward (as we have it configured) apply that label to their PRs. The CORE4 check was applied to Guardian repos in early December 2025.Atomicity of creation & labelling of PRs using the GitHub API
When PRs are created through the GitHub API (eg, by Scala Steward), there is no documented way to both create and label them in a single atomic API operation:
...so PRs are first created, and then labelled.
Problem
The CORE4-labelling check currently obtains the labels upon PRs by reading the webhook payload object for
pull_request:.github/.github/workflows/require-label.yaml
Line 16 in 6ba60f6
...but the webhook payload does not change, even if the workflow is manually re-run - only a new webhook event can pick up label changes.
This leads to the rare failure case where a CORE4 check run fails, and continues to fail, on a PR with valid labelling:
...this was seen with this Scala Steward PR, where the CORE4 check failed, and continues to fail:
Workaround
Remove the label, wait 10 seconds, and then re-add it. This will create 2 new webhook payloads, and the second - so long as it runs after the first - will have the label in it.
Fix
Use the GitHub API, not the the event payload, to get the labelling information - so simply re-running the GitHub workflow will work to clear any problem - and as the GitHub API information is being generated seconds later than the webhook, it stands more chance of including the applied label.
Testing
Tried out this branch with guardian/play-secret-rotation#580, where it worked well as I added and removed labels - the only difference being, this updated approach would be able to recover by just re-running the job if anything went wrong, rather than toggling the label.
See also