-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
CI: PrAssignee.yml
: .catch()
and return the error object if 404 is encountered when checking collaborator status
#58550
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
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 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -38,7 +38,11 @@ jobs: | |||||||||||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||||||||||||
with: | ||||||||||||
retries: 5 # retry GitHub API requests up to 5 times, with exponential backoff | ||||||||||||
retry-exempt-status-codes: 403 | ||||||||||||
retry-exempt-status-codes: "403,404" | ||||||||||||
# In the above list: | ||||||||||||
# | ||||||||||||
# - 404 is in the list because we will always hit a 404 when the PR author is not | ||||||||||||
# a committer. This 404 is normal and expected. | ||||||||||||
Comment on lines
+41
to
+45
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.
Suggested change
This isn't needed per the readme of plugin-retry.jl
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. I was actually wanting to retry on 400. In the past (although I don't have an example handy), I've seen GitHub give intermittent 400 in situations that were actually GitHub's fault server-side1. So I'd want us to still retry on 400 - I'm fine with adding the other above-listed codes to our manual list. With that being said, the only one we actually know that we expect to see (in the normal/happy path) is 404, so really we could remove 403 (from our manual list) and just have 404 in our manual list. Footnotes
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. I made a PR to update the list and comment #58555 |
||||||||||||
script: | | ||||||||||||
const oldPrAssignees = context.payload.pull_request.assignees | ||||||||||||
.map(obj => obj.login) | ||||||||||||
|
@@ -55,7 +59,26 @@ jobs: | |||||||||||
headers: { | ||||||||||||
'X-GitHub-Api-Version': '2022-11-28' | ||||||||||||
} | ||||||||||||
}) | ||||||||||||
}).catch((error) => { | ||||||||||||
// So, I'm not sure if the error is being thrown by `@octokit/request.js` or | ||||||||||||
// `@octokit/plugin-retry.js`. I suspect that the initial error is thrown by | ||||||||||||
// `request.js`, and is subsequently propagated by `plugin-retry.js`. | ||||||||||||
// | ||||||||||||
// Anyway, the docs for `request.js` say the following: | ||||||||||||
// | ||||||||||||
// > If an error occurs, the promise is rejected with an `error` object | ||||||||||||
//> containing 3 keys to help with debugging: | ||||||||||||
// > | ||||||||||||
// > - `error.status` The http response status code | ||||||||||||
// > - `error.request` The request options such as `method`, `url` and `data` | ||||||||||||
// > - `error.response` The http response object with `url`, `headers`, and `data` | ||||||||||||
// | ||||||||||||
// Source: https://github.com/octokit/request.js/blob/main/README.md#request | ||||||||||||
// | ||||||||||||
// So, inside this `.catch()`, we simply return that `error` object. | ||||||||||||
|
||||||||||||
return error; | ||||||||||||
}); | ||||||||||||
if (isCollaboratorResponseObj.status == 204) { | ||||||||||||
var isCollaborator = true; | ||||||||||||
} else if (isCollaboratorResponseObj.status == 404) { | ||||||||||||
|
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.