AlexSim93 / pull-request-analytics-action

Provides informative reports on team and developer metrics, based on data from pull requests and code reviews
MIT License
110 stars 10 forks source link

`comment.user` can be null #5

Closed yshrsmz closed 11 months ago

yshrsmz commented 11 months ago

Hi, thanks for this great tool!

I have encountered the following error while running this action.

Run AlexSim93/pull-request-analytics-action@v1.3.1
Initiating data request.
RATE LIMIT REMAINING BEFORE REQUESTS:  5000
RATE LIMIT REMAINING BEFORE REQUESTS:  5000
Batch request #1 out of 2
Batch request #1 out of 4
Batch request #2 out of 2
Batch request #2 out of 4
RATE LIMIT REMAINING AFTER REQUESTS:  4713
Batch request #3 out of 4
Batch request #4 out of 4
RATE LIMIT REMAINING AFTER REQUESTS:  4563
Data successfully retrieved. Starting report calculations.
/home/runner/work/_actions/AlexSim93/pull-request-analytics-action/v1.3.1/build/index.js:411
    const reviewComments = comments[index]?.filter((comment) => pullRequestLogin !== comment.user.login);
                                                                                                  ^

TypeError: Cannot read properties of null (reading 'login')
    at /home/runner/work/_actions/AlexSim93/pull-request-analytics-action/v1.3.1/build/index.js:411:99
    at Array.filter (<anonymous>)
    at prepareDiscussions (/home/runner/work/_actions/AlexSim93/pull-request-analytics-action/v1.3.1/build/index.js:411:45)
    at /home/runner/work/_actions/AlexSim93/pull-request-analytics-action/v1.3.1/build/index.js:51:40
    at Array.forEach (<anonymous>)
    at collectData (/home/runner/work/_actions/AlexSim93/pull-request-analytics-action/v1.3.1/build/index.js:32:26)
    at main (/home/runner/work/_actions/AlexSim93/pull-request-analytics-action/v1.3.1/build/index.js:[18](https://github.com/dotmoneyjp/meta/actions/runs/7203965954/job/19624664464#step:3:19)74:49)

Node.js v[20](https://github.com/yshrsmz/meta/actions/runs/7203965954/job/19624664464#step:3:21).8.1

It seems like that comment.user becomes null if that user is deleted.

The deleted user looks like this in GitHub UI

スクリーンショット 2023-12-14 12 47 16

I think we should check if user exists everywhere, even though the type definition says it is non-null.

yshrsmz commented 11 months ago

Or perhaps filter out comments & PRs created by deleted users?

AlexSim93 commented 11 months ago

Thanks. You're right. User is null, when they have deleted account. I have fixed it in PR and released fixes(v1.4.1)

yshrsmz commented 11 months ago

Thanks for the quick fix! I confirmed the issue is now resolved.