From 41ae23c0e7bc34853d2e9b8be63b0c599174259c Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Mon, 25 Aug 2025 15:17:01 +0200 Subject: [PATCH] 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`. --- .github/workflows/dismissed-review.yml | 2 +- ci/github-script/reviews.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dismissed-review.yml b/.github/workflows/dismissed-review.yml index 1d99c1c9cf06..224ea0af7249 100644 --- a/.github/workflows/dismissed-review.yml +++ b/.github/workflows/dismissed-review.yml @@ -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!) { diff --git a/ci/github-script/reviews.js b/ci/github-script/reviews.js index 107ec3975c98..f10f141d84cb 100644 --- a/ci/github-script/reviews.js +++ b/ci/github-script/reviews.js @@ -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' ||