Repository navigation
Treat stacked-PR update_branch API failures as non-fatal in PR Sous Chef safe outputs
#53300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
1c7a623
b259fe7
96f593c
cf51145
b494d67
8f5ba56
2ed52ee
4a098c4
97e7f8b
0384389
8861800
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1009,6 +1009,28 @@ describe("update_pull_request.cjs - update_branch behavior", () => { | |
| expect(mockCore.warning).toHaveBeenCalledWith(expect.stringContaining("branch from base (non-fatal)")); | ||
| }); | ||
|
|
||
| it("should continue title/body updates when updateBranch reports stacked-PR unsupported", async () => { | ||
| const stackedPRError = new Error("Updating a stacked PR's branch via this endpoint is not supported."); | ||
| stackedPRError.status = 422; | ||
| mockGithub.rest.pulls.updateBranch.mockRejectedValueOnce(stackedPRError); | ||
|
|
||
| const handler = await updatePRModule.main({ update_branch: true }); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/tdd] Missing assertion: this test relies on the 💡 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in 0384389: added an assertion in |
||
| const result = await handler({ | ||
| pull_request_number: 100, | ||
| title: "Updated PR", | ||
| }); | ||
|
|
||
| expect(result.success).toBe(true); | ||
| expect(mockGithub.rest.pulls.updateBranch).toHaveBeenCalledTimes(1); | ||
| expect(mockGithub.rest.pulls.update).toHaveBeenCalledWith({ | ||
| owner: "testowner", | ||
| repo: "testrepo", | ||
| pull_number: 100, | ||
| title: "Updated PR", | ||
| }); | ||
| expect(mockCore.warning).toHaveBeenCalledWith(expect.stringContaining("branch from base (non-fatal)")); | ||
| }); | ||
|
|
||
| it("should continue title/body updates when updateBranch gets workflows-scope-required 403 (scope phrase variant)", async () => { | ||
| // Message matches only the "`workflows` scope may be required" branch of hasWorkflowsScopeRequired. | ||
| const scopeError = new Error("Validation failed; `workflows` scope may be required due to timeout in check."); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot add logging before any return statement with reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented in 2ed52ee. Added explicit
core.info(...)logging with reason before each return decision in update-branch classification/fallback paths (including fatal vs non-fatal classification and stacked-PR stack-sync fallback exits).