Skip to content

fix(remediation): avoid read-after-write lag on freshly created fix branches - #18

Merged
franzramadhan merged 1 commit into
mainfrom
fix/remediation-branch-read-after-write-lag
Aug 5, 2026
Merged

fix(remediation): avoid read-after-write lag on freshly created fix branches#18
franzramadhan merged 1 commit into
mainfrom
fix/remediation-branch-read-after-write-lag

Conversation

@franzramadhan

Copy link
Copy Markdown
Contributor

Summary

  • CommitFiles re-fetched the branch ref via GetRef immediately after EnsureBranch created it, and GitHub's Data API can 404 on that immediate re-read (read-after-write lag), causing remediation to fail with fetching branch ... 404 Not Found.
  • EnsureBranch now returns the branch's resulting head SHA (existing ref's SHA, or fromSHA when just created) and CommitFiles takes it as a parameter instead of re-fetching, removing the redundant, consistency-sensitive call.
  • Observed in production logs: actions-pinned remediation on reearth/reearth-cms failed twice with this error while npm-ci-required (whose branch already existed from a prior run) succeeded.

Test plan

  • go build ./...
  • go vet ./...
  • go test ./... (all packages pass)
  • Updated internal/github/write_test.go and internal/remediation/engine_full_test.go for the new EnsureBranch/CommitFiles signatures

…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-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 78.06%. Comparing base (b185063) to head (604fbbb).

Files with missing lines Patch % Lines
internal/remediation/engine.go 66.66% 0 Missing and 1 partial ⚠️
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              
Flag Coverage Δ
unittests 78.06% <90.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@franzramadhan
franzramadhan merged commit 3c43703 into main Aug 5, 2026
1 check passed
@franzramadhan
franzramadhan deleted the fix/remediation-branch-read-after-write-lag branch August 5, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants