ci,workflows: deal with ghost reviews

When a user deletes their account, they appear as a "ghost user". This
user is represented as `null` on API requests. If such a user had posted
a review before, this breaks a few places, which assume to be able to
access `user.login`.
This commit is contained in:
Wolfgang Walther 2025-08-25 15:17:01 +02:00
parent 3ce8806f8a
commit 41ae23c0e7
No known key found for this signature in database
GPG key ID: B39893FA5F65CAE1
2 changed files with 3 additions and 3 deletions

View file

@ -49,7 +49,7 @@ jobs:
repo: context.repo.repo,
pull_number: pull_request.number
})).filter(review =>
review.user.login == 'github-actions[bot]' &&
review.user?.login == 'github-actions[bot]' &&
review.state == 'DISMISSED'
).map(review => github.graphql(`
mutation($node_id:ID!) {

View file

@ -12,7 +12,7 @@ async function dismissReviews({ github, context, dry }) {
pull_number,
})
)
.filter((review) => review.user.login === 'github-actions[bot]')
.filter((review) => review.user?.login === 'github-actions[bot]')
.map(async (review) => {
if (review.state === 'CHANGES_REQUESTED') {
await github.rest.pulls.dismissReview({
@ -46,7 +46,7 @@ async function postReview({ github, context, core, dry, body }) {
})
).find(
(review) =>
review.user.login === 'github-actions[bot]' &&
review.user?.login === 'github-actions[bot]' &&
// If a review is still pending, we can just update this instead
// of posting a new one.
(review.state === 'CHANGES_REQUESTED' ||