Skip to content

Action fails with "Cannot read properties of undefined (reading 'user')" #104

@tlevesque-ueat

Description

@tlevesque-ueat

Sometimes the action fails with the following error:

Cannot read properties of undefined (reading 'user')

Here's the full log for the step with debug enabled:

##[debug]Evaluating condition for step: 'Compute pull request stats'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Compute pull request stats
##[debug]Loading inputs
##[debug]Evaluating: github.token
##[debug]Evaluating Index:
##[debug]..Evaluating github:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'token'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Loading env
Run flowwer-dev/pull-request-stats@v3.2.2
  with:
    period: 14
    charts: true
    githubToken: ***
    limit: 0
    publishAs: COMMENT
    disableLinks: false
    telemetry: true
    disable-links: false
##[debug]Inputs: {
##[debug]  "currentRepo": "<redacted>",
##[debug]  "githubToken": "***",
##[debug]  "personalToken": "***",
##[debug]  "pullRequestId": "PR_kwDOJWZ0oc6sLAAe",
##[debug]  "org": "",
##[debug]  "repos": [
##[debug]    "<redacted>"
##[debug]  ],
##[debug]  "sortBy": "",
##[debug]  "mainStats": [
##[debug]    "totalReviews",
##[debug]    "timeToReview",
##[debug]    "totalComments"
##[debug]  ],
##[debug]  "publishAs": "COMMENT",
##[debug]  "periodLength": 14,
##[debug]  "displayCharts": true,
##[debug]  "disableLinks": false,
##[debug]  "limit": 0,
##[debug]  "excludeStr": "",
##[debug]  "includeStr": "",
##[debug]  "telemetry": true,
##[debug]        "deletions": 1,
##[debug]        "publishedAt": "2025-09-29T01:18:53.000Z",
##[debug]        "cursor": "Y3Vyc29yOjk=",
##[debug]        "id": "PR_kwDOJWZ0oc6q_P3A",
##[debug]        "lines": 2,
##[debug]        "reviews": []
##[debug]      },
##[debug]      {
##[debug]        "author": {},
##[debug]        "additions": 2,
##[debug]        "deletions": 2,
##[debug]        "publishedAt": "2025-09-29T00:15:42.000Z",
##[debug]        "cursor": "Y3Vyc29yOjEw",
##[debug]        "id": "PR_kwDOJWZ0oc6q-3tZ",
##[debug]        "lines": 4,
##[debug]        "reviews": []
##[debug]      },
##[debug]      {
##[debug]        "author": {},
##[debug]        "additions": 1,
##[debug]        "deletions": 1,
##[debug]        "publishedAt": "2025-09-29T01:18:48.000Z",
##[debug]        "cursor": "Y3Vyc29yOjEx",
##[debug]        "id": "PR_kwDOJWZ0oc6q_P1b",
##[debug]        "lines": 2,
##[debug]        "reviews": []
##[debug]      }
##[debug]    ],
##[debug]    "stats": {
##[debug]      "openedPullRequests": 11,
##[debug]      "totalObservations": 0,
##[debug]      "medianObservations": null,
##[debug]      "revisionSuccessRate": null,
##[debug]      "additions": 125,
##[debug]      "deletions": 125,
##[debug]      "lines": 250
##[debug]    }
##[debug]  }
##[debug]]
Analyzed stats for 0 reviewers
##[debug][]
##[debug]Analyzed entries: 0
##[debug]Table content built successfully
##[debug]Execution failed with error: Cannot read properties of undefined (reading 'user')
##[debug]TypeError: Cannot read properties of undefined (reading 'user')
##[debug]    at module.exports (/home/runner/work/_actions/flowwer-dev/pull-request-stats/v3.2.2/dist/index.js:42667:35)
##[debug]    at module.exports (/home/runner/work/_actions/flowwer-dev/pull-request-stats/v3.2.2/dist/index.js:42689:19)
##[debug]    at module.exports (/home/runner/work/_actions/flowwer-dev/pull-request-stats/v3.2.2/dist/index.js:44144:25)
##[debug]    at run (/home/runner/work/_actions/flowwer-dev/pull-request-stats/v3.2.2/dist/index.js:42168:9)
##[debug]    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
##[debug]    at async module.exports (/home/runner/work/_actions/flowwer-dev/pull-request-stats/v3.2.2/dist/index.js:42193:21)
##[debug]    at async run (/home/runner/work/_actions/flowwer-dev/pull-request-stats/v3.2.2/dist/index.js:49758:5)
Error: Cannot read properties of undefined (reading 'user')
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Compute pull request stats

As far as I can tell, it happens here:

const firstUser = table.rows[0].user;

And I'm pretty sure it's related to the "Analyzed stats for 0 reviewers" in the logs.

This repo doesn't have much activity, but we have a tool (Mend Renovate) that frequently sends pull requests to keep dependencies up to date. The tool is configured to self-approve and merge automatically when it's a minor update (if all required checks pass, of course). Which means there's frequently zero reviews by humans over the configured period (14 days in that case), even if there are pull requests. I suspect this is what's causing the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions