-
Notifications
You must be signed in to change notification settings - Fork 476
fix: return no-op for stale review_id 404 in dismiss_pull_request_review #49745
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 all commits
d768f17
9f3c78b
2a92b66
6aa73e4
879bf63
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 |
|---|---|---|
|
|
@@ -365,4 +365,39 @@ describe("dismiss_pull_request_review", () => { | |
| expect(result.error).toContain("truncated"); | ||
| expect(mockListReviews).toHaveBeenCalledTimes(10); | ||
| }); | ||
|
|
||
| it("returns skipped no-op when getReview returns 404 for an explicit review_id", async () => { | ||
| const notFoundError = Object.assign(new Error("Not Found"), { status: 404 }); | ||
| mockGetReview.mockRejectedValueOnce(notFoundError); | ||
|
|
||
| const result = await handler({ | ||
| type: "dismiss_pull_request_review", | ||
| review_id: 123, | ||
| justification: "This stale review no longer reflects the updated implementation.", | ||
| }); | ||
|
|
||
| expect(result.success).toBe(true); | ||
| expect(result.skipped).toBe(true); | ||
| expect(result.reason).toContain("review no longer exists"); | ||
| expect(result.review_id).toBe(123); | ||
| expect(result.pull_request_number).toBe(42); | ||
| expect(result.repo).toBe("test-owner/test-repo"); | ||
| expect(mockDismissReview).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("fails with review context when getReview returns a non-404 error", async () => { | ||
| const serverError = Object.assign(new Error("Internal Server Error"), { status: 500 }); | ||
| mockGetReview.mockRejectedValueOnce(serverError); | ||
|
|
||
| const result = await handler({ | ||
| type: "dismiss_pull_request_review", | ||
| review_id: 123, | ||
| justification: "This stale review no longer reflects the updated implementation.", | ||
| }); | ||
|
|
||
| expect(result.success).toBe(false); | ||
| expect(result.error).toContain("Failed to fetch review 123 on test-owner/test-repo#42"); | ||
| expect(result.error).toContain("Internal Server Error"); | ||
| expect(mockDismissReview).not.toHaveBeenCalled(); | ||
| }); | ||
|
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. No test asserts that non-404 errors from 💡 DetailsThe new test only exercises the happy path for the 404 no-op. There is no negative test verifying that a non-404 error (e.g. Suggested addition: it("still fails when getReview returns a non-404 error", async () => {
const serverError = Object.assign(new Error("Internal Server Error"), { status: 500 });
mockGetReview.mockRejectedValueOnce(serverError);
const result = await handler({
type: "dismiss_pull_request_review",
review_id: 123,
justification: "...",
});
expect(result.success).toBe(false);
expect(mockDismissReview).not.toHaveBeenCalled();
});
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. Fixed in |
||
| }); | ||
|
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] The test doesn't assert 💡 Suggested additionsexpect(result.pull_request_number).toBeDefined();
expect(result.repo).toMatch(/\//);All fields of the contract surface should be covered so a future refactor can't silently drop them. @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. Fixed in |
||
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.
Non-404 errors are re-thrown without added context, making them harder to diagnose in workflow logs when many reviews/PRs are processed.
💡 Details
When
getReviewError.statusis anything other than 404 (403, 500, rate-limit, network error), it propagates viathrow getReviewErrorunchanged. The outercatch (error)at the bottom ofmainonly recordsgetErrorMessage(error), so the resulting failure message won't mention whichreview_id/pull_request_numberthe lookup was for. In a workflow that fans out over multiple dismiss requests, this makes triage harder.Suggested fix:
Rationale: preserving the original error type/stack while enriching the message keeps the fatal-failure behavior intact but makes logs actionable.
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.
Fixed in
6aa73e4./home/runner/work/gh-aw/gh-aw/actions/setup/js/dismiss_pull_request_review.cjsnow enriches non-404getReviewfailures with thereview_idandowner/repo#pull_request_numbercontext before rethrowing, so fatal safe-output logs stay actionable.