Skip to content

Treat stacked-PR update_branch API failures as non-fatal in PR Sous Chef safe outputs - #53300

Merged
pelikhan merged 11 commits into
mainfrom
copilot/aw-fix-failed-jobs-pr-sous-chef
Aug 17, 2026
Merged

Treat stacked-PR update_branch API failures as non-fatal in PR Sous Chef safe outputs#53300
pelikhan merged 11 commits into
mainfrom
copilot/aw-fix-failed-jobs-pr-sous-chef

Conversation

Copilot AI commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

PR Sous Chef failed its safe_outputs job when update_pull_request(update_branch: true) hit GitHub’s stacked-PR limitation (Updating a stacked PR's branch via this endpoint is not supported). This change narrows error handling so that this known branch-update condition does not fail the safe-output pipeline.

  • Root-cause-aligned error classification

    • Updated actions/setup/js/update_pull_request.cjs to classify the stacked-PR update-branch API rejection as non-fatal inside isNonFatalUpdateBranchError(...).
    • Behavior now matches other tolerated update-branch edge cases (e.g., no-op base sync scenarios), allowing processing to continue.
  • Targeted regression coverage

    • Added a focused case in actions/setup/js/update_pull_request.test.cjs to assert that when update-branch returns the stacked-PR unsupported error, title/body updates continue and the operation is surfaced as non-fatal.
const hasStackedPRUnsupportedError =
  message.includes("updating a stacked pr's branch via this endpoint is not supported");

if (hasStackedPRUnsupportedError) {
  return true; // treat as non-fatal for update_branch path
}

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 21.7 AIC · ⌖ 7.61 AIC · ⊞ 8.8K ·
Comment /souschef to run again


_Run: https://github.com/github/gh-aw/actions/runs/32028986454_> Generated by 👨‍🍳 PR Sous Chef · gpt54 · 6.57 AIC · ⌖ 7.37 AIC · ⊞ 6.3K ·

Comment /souschef to run again


\nrun: https://github.com/github/gh-aw/actions/runs/32032749148> Generated by 👨‍🍳 PR Sous Chef · gpt54 · 6.96 AIC · ⌖ 5.94 AIC · ⊞ 8.8K ·

Comment /souschef to run again

Copilot AI linked an issue Aug 17, 2026 that may be closed by this pull request
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failed jobs in PR Sous Chef workflow Treat stacked-PR update_branch API failures as non-fatal in PR Sous Chef safe outputs Aug 17, 2026
Copilot AI requested a review from pelikhan August 17, 2026 05:26
@github-actions

Copy link
Copy Markdown
Contributor

PR Triage

Category: bug | Risk: low | Score: 40/100

  • Impact: 18/50 | Urgency: 12/30 | Quality: 10/20

Recommended action: batch_review (grouped with #53302, #53301 as small workflow/agent fixes)

Generated by 🔧 PR Triage Agent · auto · 43 AIC · ⌖ 2.45 AIC · ⊞ 8.1K ·

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot fix update-branch to handle stacked PRs if possible

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Handles GitHub’s stacked-PR branch-update limitation without blocking PR Sous Chef safe outputs.

Changes:

  • Classifies the known stacked-PR API rejection as non-fatal.
  • Adds regression coverage ensuring title updates continue.
Show a summary per file
File Description
actions/setup/js/update_pull_request.cjs Adds stacked-PR error classification.
actions/setup/js/update_pull_request.test.cjs Tests non-fatal handling and continued updates.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread actions/setup/js/update_pull_request.cjs Outdated
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix update-branch to handle stacked PRs if possible

Implemented in 96f593c. update_branch now treats the stacked-PR unsupported error as non-fatal only when it comes back as HTTP 422, and non-422 responses with that phrase remain fatal. Added a regression test to cover the non-422 case.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /diagnosing-bugs, /tdd, and /codebase-design — requesting changes on two correctness issues and a test gap.

📋 Key Themes & Highlights

Key Themes

  • Dead code (correctness): The isStackedPRUnsupportedUpdateBranchError guard added inside isNonFatalUpdateBranchError (line 67) is unreachable — executePRUpdate dispatches that error type first, before isNonFatalUpdateBranchError is ever called with it.
  • Non-standard API field: pullRequest?.stack?.number (line 119) is not in the public GitHub REST API shape for pulls.get, making the first resolution path a silent no-op on every call.
  • Test gap: The first stacked-PR test (should continue title/body updates when updateBranch reports stacked-PR unsupported) doesn't assert that request was called for stack resolution, so a regression bypassing tryStackedPRUpdateBranch entirely would go undetected.

Positive Highlights

  • ✅ Root cause is correctly identified and the fix is narrowly scoped.
  • ✅ Three new focused tests for the stacked-PR path including success, stack-sync-fails, and wrong-status-is-fatal scenarios — good regression coverage.
  • ✅ All new core.info log lines clearly explain the classification decision, which will make future debugging much easier.
  • ✅ Extracting getErrorStatus was the right refactor — eliminates repeated traversal logic.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 40.3 AIC · ⌖ 9.17 AIC · ⊞ 7.7K
Comment /matt to run again

// GitHub update-branch API also returns 403 with this message when a PR contains workflow
// file changes and the check times out, rather than the usual "refusing to allow" phrase.
const hasWorkflowsScopeRequired = message.includes("`workflows` scope may be required") || message.includes("unable to determine if workflow can be created or updated");
if (isStackedPRUnsupportedUpdateBranchError(error)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/diagnosing-bugs] Dead code: this isStackedPRUnsupportedUpdateBranchError check inside isNonFatalUpdateBranchError is unreachable. The call-site at line 200 dispatches stacked-PR errors first, before isNonFatalUpdateBranchError is called with them.

💡 Suggested fix

Remove this guard from isNonFatalUpdateBranchError. The stacked-PR case is now exclusively handled by the call-site dispatch, so this branch can never be reached.

Alternatively, invert the dependency: remove the call-site check and keep the logic centralised inside isNonFatalUpdateBranchError — but then the separate tryStackedPRUpdateBranch call in executePRUpdate would need restructuring too.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 0384389: removed the unreachable stacked-PR branch from isNonFatalUpdateBranchError(...) and kept stacked-PR handling at the call-site dispatch in executePRUpdate(...).

stackedPRError.status = 422;
mockGithub.rest.pulls.updateBranch.mockRejectedValueOnce(stackedPRError);

const handler = await updatePRModule.main({ update_branch: true });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] Missing assertion: this test relies on the beforeEach mock returning an empty stacks list, causing tryStackedPRUpdateBranch to silently fall back to the warning path — but there is no assertion that request was actually called, so a regression where tryStackedPRUpdateBranch is skipped entirely would still pass.

💡 Suggested addition
// Verify the sync path was attempted before falling back
expect(mockGithub.request).toHaveBeenCalledWith(
  "GET /repos/{owner}/{repo}/stacks",
  expect.objectContaining({ pull_request: 100 })
);

This pins the intended behaviour: when the stacked-PR error fires, the code must always attempt stack resolution before warning.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 0384389: added an assertion in update_pull_request.test.cjs to verify GET /repos/{owner}/{repo}/stacks is attempted in the stacked-PR unsupported path before non-fatal fallback.

repo: context.repo.repo,
pull_number: prNumber,
});
if (typeof pullRequest?.stack?.number === "number") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/codebase-design] pullRequest?.stack?.number is not part of the standard GitHub REST API response for pulls.get. This field will always be undefined in practice, making the first resolution path a no-op and adding a redundant API call on every stacked-PR failure.

💡 Suggestion

If there is no documented stack field on the pulls API response, remove the pulls.get lookup entirely and go directly to GET /repos/{owner}/{repo}/stacks. That removes the silent no-op and an unnecessary API round-trip.

If the field is available via a private/beta API, add a comment explaining the source and the expected shape so reviewers and future editors understand why it is accessed.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 0384389: removed the pulls.get stack-field lookup and now resolve stack membership directly via GET /repos/{owner}/{repo}/stacks before sync.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot pr stacks are new and the octokit api might be lagging behind

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot run pr-finisher skill

Done. I ran the pr-finisher pass and pushed the resulting fixes in 0384389, including local validation and maintainer-visible status updates.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot this PR is ready for the next finishing pass.

Please address these items, newest first:

  • Recent maintainer note: pr stacks are new and the octokit api might be lagging behind — make sure the implementation handles that reality explicitly and summarize any remaining limitation.
  • Refresh the branch with the latest base changes if needed.
  • Run the pr-finisher skill after the fixes and summarize the remaining maintainer-visible status.

Run: https://github.com/github/gh-aw/actions/runs/32032749148

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 6.96 AIC · ⌖ 5.94 AIC · ⊞ 8.8K ·
Comment /souschef to run again

Copilot AI commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot pr stacks are new and the octokit api might be lagging behind

Handled: the stacked-PR path uses raw github.request(...) endpoints (not typed octokit.rest methods), so it works even when Octokit’s generated API surface lags. If stacks endpoints are unavailable or return errors, the code logs the reason and falls back to the existing non-fatal update_branch behavior.

Copilot AI commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot this PR is ready for the next finishing pass.

Please address these items, newest first:...

Verified in current code: stacked-PR handling calls raw REST routes via github.request("GET /repos/{owner}/{repo}/stacks") and github.request("POST /repos/{owner}/{repo}/stacks/{stack_number}/sync"), so it does not depend on typed Octokit rest support for new stacks APIs. Remaining limitation: if stacks endpoints are unavailable, permissions are missing, or response shape changes (e.g., no resolvable stack.number), we log the reason and keep the existing non-fatal fallback (PR processing continues, but branch sync may be skipped).

@pelikhan

Copy link
Copy Markdown
Collaborator

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot this PR is ready for the next finishing pass.

Please address these items, newest first:

  • Failed checks: Unit tests (D-L).
  • Recent maintainer request: fix the failing job.
  • Refresh the branch with the latest base changes if needed.
  • Run the pr-finisher skill after the fixes and summarize the remaining maintainer-visible status.

Run: https://github.com/github/gh-aw/actions/runs/32034893678

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 12.8 AIC · ⌖ 5.75 AIC · ⊞ 8.8K ·
Comment /souschef to run again

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix https://github.com/github/gh-aw/actions/runs/32033089517/job/95398882936

Fixed in 8861800.

I reproduced the linked failure and updated pkg/cli/daily_regression_audit_workflow_contract_test.go so it no longer hard-codes python3. The contract now accepts either python3 or jq in .github/workflows/daily-regression-audit-kiro.md and validates matching --allow-tool shell(...) entries in the lock file, including stale-entry checks.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please take another pass on this PR. Please address the remaining maintainer-visible failing check (Unit tests (D-L)) and recent maintainer follow-up, refresh the branch if needed, and run the pr-finisher skill before handing back to a maintainer.

Run: https://github.com/github/gh-aw/actions/runs/32038496983

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 11.8 AIC · ⌖ 6.86 AIC · ⊞ 8.8K ·
Comment /souschef to run again

@pelikhan
pelikhan merged commit 87181f8 into main Aug 17, 2026
1 of 2 checks passed
@pelikhan
pelikhan deleted the copilot/aw-fix-failed-jobs-pr-sous-chef branch August 17, 2026 14:28
Copilot stopped work on behalf of gh-aw-bot due to an error August 17, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw] Failed jobs: PR Sous Chef

4 participants