fix(#5475): close stale scaffold PRs when switching install modes#5478
fix(#5475): close stale scaffold PRs when switching install modes#5478fullsend-ai-coder[bot] wants to merge 1 commit into
Conversation
|
🤖 Finished Review · ✅ Success · Started 5:29 PM UTC · Completed 5:46 PM UTC |
Site previewPreview: https://4fa0bf8e-site.fullsend-ai.workers.dev Commit: |
ReviewFindingsMedium
Low
Previous runReviewFindingsMedium
Low
Labels: PR modifies the scaffold install flow (internal/layers/commit.go) and the forge abstraction (internal/forge/), fixing a bug in install mode switching |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
/fs-review - Rebase, fix the review issues and resolve the conversations, and fix the CI coverage test failure. |
|
🤖 Review · |
|
/fs-fix - Rebase, fix the review issues and resolve the conversations, and fix the CI coverage test failure. |
|
🤖 Finished Fix · ✅ Success · Started 9:24 PM UTC · Completed 9:38 PM UTC |
Address review feedback on PR #5478: - Add Author field to ChangeProposal and populate it from the GitHub user.login and GitLab author.username API response fields. - Filter closeStaleScaffoldPRs to only close PRs authored by the authenticated user, preventing accidental closure of PRs opened by external contributors on predictable scaffold branch names. - Guard closeStaleScaffoldPRs behind a same-repo check so it is skipped in the fork path, avoiding unnecessary 403 warnings when a non-owner token attempts to close upstream PRs. - Add tests for author filtering (skip different author, close empty author for backwards compat) and fork-path skip behavior. - Add TestCloseChangeProposal for GitHub and GitLab forge packages to improve patch coverage. - Update TestListRepoPullRequests to cover head/base/author fields. Addresses review feedback on #5478
🔧 Fix agent — iteration 1 (human-triggered)Addressed 3 of 7 review findings with code fixes: added author filtering to prevent closing external contributors' PRs, added fork-path guard to avoid unnecessary 403 warnings, and improved test coverage with tests for CloseChangeProposal (GitHub/GitLab), author field population, author filtering, and fork-path skip. Disagreed with 4 findings (scope-mismatch is a process concern, architectural-misalignment is premature abstraction, error-handling is pre-existing pattern, unvalidated-ref-path is structurally safe). Rebase was not possible in sandbox (no fetch access). Fixed (3):
Disagreed (4):
Tests: passed Updated by fullsend fix agent |
|
/fs-review |
|
🤖 Finished Review · ✅ Success · Started 10:47 PM UTC · Completed 11:05 PM UTC |
|
/fs-fix - Rebase, fix the review issues and resolve the conversations. |
|
🤖 Finished Fix · ❌ Failure · Started 2:06 AM UTC · Completed 2:14 AM UTC |
|
The fix agent completed, but the post-fix script failed before finishing. Workflow run: https://github.com/fullsend-ai/.fullsend/actions/runs/29973488744 Details: |
|
/fs-fix - Rebase, fix the review issues and resolve the conversations. |
|
🤖 Finished Fix · ✅ Success · Started 2:24 PM UTC · Completed 2:32 PM UTC |
🔧 Fix agent — iteration 2 (human-triggered)Rebased onto main. Fixed 1 review finding (fail-open-author-check → fail-closed) with updated test. Disagreed with 3 informational findings (scope-mismatch, architectural-misalignment, unvalidated-ref-path) that are either process concerns or structurally safe by design. Fixed (2):
Disagreed (3):
Tests: passed Decision points
Updated by fullsend fix agent |
Address review feedback on PR #5478: - Add Author field to ChangeProposal and populate it from the GitHub user.login and GitLab author.username API response fields. - Filter closeStaleScaffoldPRs to only close PRs authored by the authenticated user, preventing accidental closure of PRs opened by external contributors on predictable scaffold branch names. - Guard closeStaleScaffoldPRs behind a same-repo check so it is skipped in the fork path, avoiding unnecessary 403 warnings when a non-owner token attempts to close upstream PRs. - Add tests for author filtering (skip different author, close empty author for backwards compat) and fork-path skip behavior. - Add TestCloseChangeProposal for GitHub and GitLab forge packages to improve patch coverage. - Update TestListRepoPullRequests to cover head/base/author fields. Addresses review feedback on #5478
Change the author ownership guard in closeStaleScaffoldPRs from fail-open to fail-closed: when pr.Author is empty (unexpected API response), skip the PR instead of closing it regardless of authorship. This prevents accidentally closing PRs opened by external contributors if the forge API ever omits the author field. Update TestCloseStaleScaffoldPRs_ClosesEmptyAuthor → SkipsEmptyAuthor to assert the new behavior. Addresses review feedback on #5478
98c7274 to
b9f6e42
Compare
When switching from per-org to per-repo install (or vice versa), the old mode's scaffold PR could remain open with a stale workflow ref pointing to deleted infrastructure. If merged, the workflow would break silently. Add closeStaleScaffoldPRs to commitBranchAndPR that lists open PRs before creating/updating the current scaffold PR. Any open PR whose head branch matches a known scaffold branch from a different install mode (fullsend/onboard for per-org, fullsend/scaffold-install for per-repo) is closed and its branch deleted. This prevents accidental merges of stale scaffold content. Changes: - Add CloseChangeProposal to forge.Client interface (GitHub, GitLab, FakeClient implementations) - Populate Head/Base/Author fields in ListRepoPullRequests responses - Add closeStaleScaffoldPRs and isKnownScaffoldBranch helpers - Call closeStaleScaffoldPRs at the start of commitBranchAndPR - Author ownership check (fail-closed) prevents closing external PRs - Fork-path guard skips cleanup when token lacks upstream permissions Signed-off-by: Claude <noreply@anthropic.com> Signed-off-by: Greg Allen <gallen@redhat.com>
b9f6e42 to
a359e9c
Compare
Summary
When switching install modes (per-org → per-repo or vice versa), the old mode's scaffold PR could remain open with a stale workflow ref pointing to deleted infrastructure (e.g., a
.fullsendrepo). If merged, the workflow would fail silently. This fix detects and closes stale scaffold PRs from the previous install mode before creating or updating the current one.Related Issue
Fixes #5475
Changes
CloseChangeProposalmethod toforge.Clientinterface with implementations for GitHub (PATCH pulls API), GitLab (PUT merge_requests with state_event: close), and FakeClientListRepoPullRequeststo populateHeadandBasefields from the API response (needed to identify which scaffold branch a PR belongs to)closeStaleScaffoldPRsfunction ininternal/layers/commit.gothat checks for open PRs from known scaffold branches (fullsend/onboard,fullsend/scaffold-install) other than the current one, closes them, and deletes their head branchescloseStaleScaffoldPRsat the start ofcommitBranchAndPRbefore any branch/PR creationTesting
go vetcleango build ./...cleanCloses #5475
Post-script verification
agent/5475-close-stale-scaffold-prs)98e92fa6db387b8e8eb751e687cfcc41e295821b..HEAD)