xt0rted/pull-request-comment-branch

Cannot read property 'name' of null

EvHaus opened this issue · 4 comments

On some (many) of our pull requests, the action fails with:

Error: Cannot read property 'name' of null
(node:1578) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'name' of null
    at Object.<anonymous> (/home/runner/work/_actions/xt0rted/pull-request-comment-branch/v1/webpack:/pull-request-comment-branch/src/PullRequests.ts:48:1)
    at Generator.next (<anonymous>)
    at fulfilled (/home/runner/work/_actions/xt0rted/pull-request-comment-branch/v1/webpack:/pull-request-comment-branch/src/PullRequests.ts:5:1)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

Unfortunately I can't share the link to the pull request as it's inside a private repository. Any idea as to what could be going wrong?

@EvHaus what's your workflow look like? Is it possible that the event triggering it isn't issue_comment? That's the only way I can see this error happening.

This is the workflow definition:

name: Test Workflow
on:
  pull_request:
    types: [closed]
jobs:
  dispatchFeatureDestroy:
    runs-on: ubuntu-latest
    steps:
      - uses: xt0rted/pull-request-comment-branch@v1
        id: comment-branch
        with:
          repo_token: ${{ secrets.GITHUB_TOKEN }}

This action was built to be used with the issue_comment event. The information it looks for in the event payload doesn't exist on pull_request events like you're using which is why the error is happening.

Makes sense. Thanks @xt0rted!