Repository navigation
fix(scaffold): stop decoding the contents API 404 body in reconcile-repos - #7620
Conversation
…epos On a failed call, gh api prints the JSON error body on stdout. The reconcile script read the shim with `--jq .content 2>/dev/null || true`, so a repo with no shim got the 404 body as its "content". The script then base64-decoded that body and treated the missing shim as a stale one. #7584 added a second decode of the same value. That decode stops the script under pipefail, so it failed every e2e run: the fresh e2e-lock repo has no shim. The defect predates #7584, which only made the decode fatal. Add fetch_contents_field. It trusts gh output only on success. A 404 (status "404" in the body, the same check delete_branch uses) means the file is absent: empty output, return 0. Any other failure warns with the repo and path, and the caller counts the repo as failed and moves on. Use it for the shim check in enroll and for the removal branch's file SHA in unenroll, where an error body could have been sent as the DELETE sha. Tests: every gh stub now behaves like real gh. A failed call prints its body unfiltered on stdout, --silent prints nothing, and --input stdin is drained. The stubs that ignored stdin made `jq ... | gh api --input -` fail at random with SIGPIPE on Linux; 3 of 4 runs of main's suite failed that way in a GNU/Linux container. New Test 7 covers a 404 taking the enroll path, a 500 failing the repo with no write, and unenroll with the file missing or unreadable on the removal branch sending no DELETE. Assisted-by: Claude Signed-off-by: Wayne Sun <gsun@redhat.com>
PR Summary by QodoHandle contents API 404s safely during repository reconciliation
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1.
|
|
🤖 Finished Review · ✅ Success · Started 2:56 PM UTC · Completed 3:12 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $4.01 |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Risk Assessment: moderate (2/5) DetailsExpanded bug fix with 43% test ratio across 7 files remains at moderate risk due to recent regression history in reconcile-repos scripts and absence of a runtime feature flag, balanced by zero protected paths and well-scoped issue alignment. Previous runRisk Assessment: moderate (2/5) DetailsExpanded bug fix with 43% test ratio across 7 files remains at moderate risk due to recent regression history in reconcile-repos scripts and absence of a runtime feature flag, balanced by zero protected paths and well-scoped issue alignment. Previous run (2)Risk Assessment: moderate (2/5) DetailsSmall scoped bug fix with 50% test ratio and no protected paths, but elevated to moderate risk due to high recent churn and regression history in reconcile-repos scripts without a feature flag. |
|
Looks good to me Previous runLooks good to me Previous run (2)Looks good to me Previous run (3)ReviewFindingsLow
|
Unenroll checked for the shim on the default branch with `gh api ... --silent 2>/dev/null`. Any failure, including a 403, 429 or 5xx, read as "already unenrolled", so a transient error left the shim in place on a disabled repo. Use fetch_contents_field there as well. A 404 is still already unenrolled. Any other failure warns, counts the repo as failed and moves on. Test 7 gains a disabled repo whose default-branch lookup returns 500. Assisted-by: Claude Signed-off-by: Wayne Sun <gsun@redhat.com>
|
🤖 Finished Review · ✅ Success · Started 3:19 PM UTC · Completed 3:34 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $3.02 |
Superseded by updated review
|
🤖 Finished Review · ✅ Success · Started 6:43 PM UTC · Completed 6:59 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $4.38 |
Superseded by updated review
The rendered repo-maintenance.yml checks out internal/scaffold/fullsend-repo/scripts/ from fullsend-ai/fullsend at the CLI's upstream ref and copies it over the vendored copy. The e2e CLI is a dev build, so that ref falls back to main. Every PR and merge-group e2e therefore ran main's scripts: a PR that changes them was never tested before merge, and a broken main failed every PR's e2e, including the PR that fixed it. Add upstreamRefOverride, a build-time-only variable. resolveUpstreamRef returns it with no tag when it is set. There is no flag or env var, so release and user builds are unchanged, and resolveAgentsRef ignores it. BuildCLIBinary stamps it with HEAD of the module root, under three conditions: the root is the top of a git checkout, HEAD is a full SHA, and that commit can be fetched from fullsend-ai/fullsend. The last check does the same fetch the rendered workflow makes, into a throwaway repo. It holds for a pushed branch, a fork PR head (through refs/pull) and a merge-group commit. A local commit that was never pushed stays unstamped and falls back to main, as before. GITHUB_SHA is not used because on pull_request_target it is the base commit. BuildModuleBinary, used by the behaviour tests and external consumers, stays unstamped. The e2e install then pins fullsend-ai/fullsend references in the scaffold (the scripts checkout and the mint-token action) to the commit under test. This is the same ref-with-no-tag shape that `github setup --fullsend-ref` already produces. Fixes #7622 Assisted-by: Claude Signed-off-by: Wayne Sun <gsun@redhat.com>
36524ff to
74edde9
Compare
|
🤖 Finished Review · ✅ Success · Started 7:08 PM UTC · Completed 7:24 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $4.53 |
Superseded by updated review
ralphbean
left a comment
There was a problem hiding this comment.
As discussed in slack, this won't be relevant soon due to the org mode removal, but if it unblocks CI now, that's good. It can be removed with org mode when that happens.
|
🤖 Finished Retro · ✅ Success · Started 10:25 PM UTC · Completed 10:34 PM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $1.55 |
|
PR #7620 (human-authored, waynesun09) fixed issue #7619's contents-API-404 decoding bug and, over a ~7.5h lifecycle, folded in a second fix for sibling issue #7622. The pipeline performed well: the first review pass (run 35877472872) caught a genuine fail-open gap in the unenroll probe, and the author fixed it within ~5 minutes via a follow-up commit — a clear example of review agent value delivered, not just rubber-stamping. The two E2E failures on the first two commits were correctly attributable to the still-open #7622 defect (not flakiness); E2E passed once the human's third commit fixed the ref-pinning issue. Final agent review approved, a human reviewer (ralphbean) approved with a scoping caveat (this code path is slated for removal per ADR 0044), and CI was clean at merge. Two investigative threads surfaced only corroborating evidence for issues already tracked elsewhere, so no new proposals were filed for either:
Overall this was a well-executed workflow with no new systemic gaps identified specific to this PR. |
Fixes #7619. Fixes #7622.
What changed
A new helper,
fetch_contents_field, reads one field from the contents API:gh's output only when the call succeeds.::warning::Failed to read <path> for <repo>and returns 1. The caller then counts that repository as failed and moves on. It never guesses whether the repository is enrolled.It replaces
--jq .content 2>/dev/null || truein two places:shalookup. A missing file is "already removed", so no DELETE is sent with an error body as thesha.Why
On a 404,
ghprints the JSON error body on stdout, and|| truekept it as the file content. #7584 added a second decode of that value underpipefail, which turned a warning into exit 1. Every e2e run now fails in the repo-maintenance step on the freshe2e-lockrepository. That includes merge-queue runs.Tests
The
ghstubs now behave like realgh:--inputstdin. Five stubs ignored it, andjq ... | gh api --input -could die of SIGPIPE underpipefail. That made main's unchanged suite pass only 1 run in 4 on GNU/Linux.New Test 7 covers five cases:
Main's unchanged script fails these tests. The fixed script passes 24/24, both in the GNU container and on macOS. Each of four mutations is killed: any failure counts as absent, a 404 counts as a failure, either call site reverted.
Scope
reconcile-repos.shis part of the deprecated per-org installation mode (ADR 0044). This is a maintenance fix: the e2e admin test still exercises that path, and the defect blocks every e2e run.A second commit applies the same helper to the unenroll default-branch probe, which the review agent flagged. Only a 404 there means "already unenrolled".
Also fixes #7622: e2e tests this PR's scripts
The e2e CLI now stamps the commit under test as the scaffold's upstream ref. It does this only when that commit can be fetched from fullsend-ai/fullsend; otherwise it falls back to
main. The stamp goes into a build-time-only variable,upstreamRefOverride, set through-ldflagsalone, with no flag and no environment variable. The renderedrepo-maintenance.ymlthen checks out this PR'sscripts/, not main's. Release builds and behaviour-test builds are unchanged.Out of scope
The same
--jq … || truepattern is still used fordefault_branchandtree.sha. Those values fail loudly further on, instead of being misread.