fix(remediation): avoid read-after-write lag on freshly created fix branches - #18
Merged
Merged
Conversation
…ranches CommitFiles re-fetched the branch ref via GetRef right after EnsureBranch created it, and GitHub's Data API can 404 on that immediate re-read. EnsureBranch now returns the branch's head SHA directly so CommitFiles no longer needs to re-fetch it.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #18 +/- ##
==========================================
- Coverage 78.08% 78.06% -0.03%
==========================================
Files 41 41
Lines 3153 3150 -3
==========================================
- Hits 2462 2459 -3
Misses 549 549
Partials 142 142
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
CommitFilesre-fetched the branch ref viaGetRefimmediately afterEnsureBranchcreated it, and GitHub's Data API can 404 on that immediate re-read (read-after-write lag), causing remediation to fail withfetching branch ... 404 Not Found.EnsureBranchnow returns the branch's resulting head SHA (existing ref's SHA, orfromSHAwhen just created) andCommitFilestakes it as a parameter instead of re-fetching, removing the redundant, consistency-sensitive call.actions-pinnedremediation onreearth/reearth-cmsfailed twice with this error whilenpm-ci-required(whose branch already existed from a prior run) succeeded.Test plan
go build ./...go vet ./...go test ./...(all packages pass)internal/github/write_test.goandinternal/remediation/engine_full_test.gofor the newEnsureBranch/CommitFilessignatures