xt0rted / pull-request-comment-branch

A GitHub Action to get the head ref and sha of a pull request comment
MIT License
87 stars 30 forks source link

Error: Cannot read property 'name' of null #213

Open flcdrg opened 2 years ago

flcdrg commented 2 years ago

Seeing this failure when I close a pull request

Run xt0rted/pull-request-comment-branch@v1
  with:
    repo_token: ***
Error: Cannot read property 'name' of null
(node:1544) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'name' of null
    at pullRequestDetails (/home/runner/work/_actions/xt0rted/pull-request-comment-branch/v1/webpack:/pull-request-comment-branch/src/PullRequests.ts:38:1)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at run (/home/runner/work/_actions/xt0rted/pull-request-comment-branch/v1/webpack:/pull-request-comment-branch/src/main.ts:9:1)
(node:1544) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1544) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Workflow looks similar to this:

name: Slash Command Dispatch
on:
  issue_comment:
    types: [created]
jobs:
  slashCommandDispatch:
    runs-on: ubuntu-latest
    if: ${{ github.actor != 'dependabot[bot]' }}
    steps:
      - name: Slash Command Repository Dispatch
        uses: peter-evans/slash-command-dispatch@v2
        with:
          token: ${{ secrets.MYTOKEN }}
          commands: |
            rebase
          permission: write
          issue-type: pull-request

      - uses: xt0rted/pull-request-comment-branch@v1
        id: comment-branch

      - name: Slash Command Workflow Dispatch
        uses: peter-evans/slash-command-dispatch@v2
        with:
          token: ${{ secrets.MYTOKEN }}
          commands: |
            lockfiles
          permission: write
          issue-type: pull-request
          dispatch-type: workflow
          static-args: ref=${{ steps.comment-branch.outputs.head_ref }}  
nbaztec commented 2 years ago

Adding a github.event.issue.state == 'open' is a workaround until this is handled properly, which it should be since it's an uncaught exception.

amirh-huma commented 3 months ago

I resorted to use this https://github.com/xt0rted/pull-request-comment-branch/pull/202 PR instead