fix(github): reuse an existing repo-docs branch ref instead of failing (#8310)#8474
Closed
galuis116 wants to merge 1 commit into
Closed
fix(github): reuse an existing repo-docs branch ref instead of failing (#8310)#8474galuis116 wants to merge 1 commit into
galuis116 wants to merge 1 commit into
Conversation
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8474 +/- ##
==========================================
- Coverage 92.47% 89.62% -2.86%
==========================================
Files 791 98 -693
Lines 79321 22792 -56529
Branches 23954 3900 -20054
==========================================
- Hits 73355 20427 -52928
+ Misses 4839 2187 -2652
+ Partials 1127 178 -949
Flags with carried forward coverage won't be shown. Click here to find out more.
|
galuis116
marked this pull request as draft
July 24, 2026 14:52
galuis116
marked this pull request as ready for review
July 24, 2026 14:54
JSONbored#8310) openRepoDocPullRequest always targets the fixed loopover/repo-docs branch, but only looks for an OPEN pull request on it before deciding to create the ref. A maintainer who closes the repo-doc PR without deleting its branch (GitHub never forces that, and an API/bot close deletes nothing) leaves the ref behind: the open-only lookup finds nothing, POST /git/refs then 422s "Reference already exists", and the outer catch turns every later refresh into { opened: false }, permanently. When the create reports that specific failure, fall back to PATCH /git/refs/{ref} with { sha, force: true } and continue into the existing PR-open path unchanged. The branch is owned solely by this feature (per the file's own header comment), never shared with contributor work, so force- updating it to the freshly built commit is safe. Deliberately narrow: - Only a 422 whose message says "Reference already exists" recovers; any other create-ref failure still propagates to the outer catch's fail-safe, so a bad sha is never force-pushed over. - The "reuse only an OPEN PR" behaviour is untouched -- a closed PR still results in a NEW pull request, only the underlying ref is reused. - Reuses the existing githubErrorStatus and errorMessage helpers rather than hand-rolling status/message extraction. Adds two tests: the 422 path force-updates the ref and still opens a fresh PR (reused: false), and an unrelated create-ref 422 issues no PATCH and degrades to opened: false.
galuis116
force-pushed
the
fix/repo-doc-branch-ref-reuse
branch
from
July 24, 2026 14:59
c1a3bd0 to
2dc4872
Compare
Contributor
|
This repository reviews pull requests one-shot: the PR must be correct as originally opened. Pushing an additional commit closes it automatically instead of restarting review — open a fresh pull request with every fix included. |
19 tasks
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
Closes #8310.
openRepoDocPullRequestalways targets the fixedloopover/repo-docsbranch (deliberately stable, per the file's header comment, so repeat runs update one PR instead of piling up duplicates). But it only checks for an open PR on that branch before deciding to create the ref:When a maintainer closes the repo-doc PR without deleting its branch -- GitHub offers a "Delete branch" button but never forces it, and a PR closed via the API or a bot deletes nothing -- the ref survives. The open-only lookup then finds nothing, the function proceeds, and
POST /git/refs422s "Reference already exists". The outertry/catchturns that into{ opened: false, reason }, so every subsequent refresh for that repo fails permanently -- both the scheduled sweep and the on-demandloopover_refresh_repo_docstool.Change
When the create reports that specific failure, fall back to
PATCH /repos/{owner}/{repo}/git/refs/{ref}with{ sha: commitSha, force: true }, then continue into the existing PR-open path unchanged. This branch is exclusively owned by this feature and never shared with contributor work, so force-updating it to the freshly built commit is safe.Deliberately narrow, matching the issue's constraints:
Reference already existsrecovers. Any other create-ref failure (e.g. an invalid sha) still propagates to the outer catch's fail-safe, so nothing is silently force-pushed over.reused: false); only the underlying ref is reused.githubErrorStatushelper and the sharederrorMessagehelper rather than hand-rolling status/message extraction.Tests
PATCHbody carries{ sha, force: true }) and still opens a fresh PR withreused: falsePATCHand degrades toopened: false, pinning the fail-safeScope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #8310).Validation
git diff --checknpm run actionlint- no workflow files touched.npm run typechecknpx vitest run test/unit/repo-doc-pr.test.ts- 33 pass (was 31).isRefAlreadyExistsErrorguard are exercised by the two tests above).npm run test:coverage(full) /test:workers/build:mcp/ui:*- not run: this is a scoped change to one backend module plus its unit test, touching no worker, MCP, or UI surface.npm audit --audit-level=moderate- no dependency changes.Safety
makeInstallationOctokit/withInstallationTokenRetrychokepoint, and the unrelated-failure test is the negative path.loopover_refresh_repo_docssimply stops failing on this case.UI Evidencesection - n/a: no visible UI/frontend/docs/extension change.Notes
loopover/repo-docs. Because the recovery is gated on both the 422 status and the "Reference already exists" message, an unrelated 422 can never reach theforce: truecall.