peter-evans / create-or-update-comment

A GitHub action to create or update an issue or pull request comment
MIT License
707 stars 113 forks source link

Error: Cannot read properties of undefined (reading 'number') #323

Closed fingolfin closed 8 months ago

fingolfin commented 8 months ago

We are using this wonderful GH action to create PR comment -- but also very often to update PR comments (see https://github.com/gap-system/PackageDistro/blob/main/.github/workflows/pull-request.yml for our full YAML file):

      - name: "Create or update comment"
        uses: peter-evans/create-or-update-comment@v4   
        with:
          token: ${{ steps.generate-token.outputs.token }}
          comment-id: ${{ steps.fc.outputs.comment-id }}
          issue-number: ${{ github.event.pull_request.number }}
          body: ${{ steps.get-comment-body.outputs.body }}
          edit-mode: replace

Today this workflow suddenly had failures I never saw before (although I should say we had been using v2 until 19 February 2024), when it tried to update an existing PR (actually the update in this case would be identical to the existing PR, which so far worked perfectly -- it just did nothing).

There error (see here for full log):

Create or update the pull request
  Attempting creation of pull request
  A pull request already exists for gap-system:automatic/cap_project
  Fetching existing pull request
  Attempting update of pull request
  Error: Cannot read properties of undefined (reading 'number')
fingolfin commented 8 months ago

I am terribly sorry -- while writing this up I got my wires crossed and looked at the wrong action. The issue really is with peter-evans/create-pull-request@v4. I'll open a new one there.

Apologies for the confusion

peter-evans commented 8 months ago

Hi @fingolfin

You're right, this does relate to create-pull-request. There is already an issue about this here: https://github.com/peter-evans/create-pull-request/issues/2790

The issue was caused by GitHub making a change to one of their APIs. You can fix it by updating to v6.

fingolfin commented 8 months ago

Thanks a lot, that did the trick!

And thanks for maintaining these actions, very much appreciated.