Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot read property 'labels' of undefined #140

Closed
nathany-copia opened this issue Aug 13, 2021 · 1 comment
Closed

Error: Cannot read property 'labels' of undefined #140

nathany-copia opened this issue Aug 13, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@nathany-copia
Copy link

Describe the bug

Changelog enforcer is unable to run on pushes to main, but it still tries.

To Reproduce

If I want the other steps in my job to still run if somebody pushes to main, I might put something like this:

name: Pull Request Workflow
on:
  pull_request:
      types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]
  push:
    branches:
      - main

Unfortunately changelog-enforcer fails with the error:

Error: Cannot read property 'labels' of undefined

Expected behavior

Likely fail because the CHANGELOG.md hasn't changed.

Workaround

Making changelog-enforcer conditional works around the issue:

- if: ${{ github.event_name == 'pull_request' }}
  uses: dangoslen/changelog-enforcer@v2
  with:
    changeLogPath: 'CHANGELOG.md'
    skipLabels: 'no changelog'
@nathany-copia nathany-copia added the bug Something isn't working label Aug 13, 2021
@dangoslen
Copy link
Owner

Hey @anmlnath! Thanks for reporting this.

I agree this is a bug. The enforcer is designed to run within the context of a pull_request event, but that isn't documented properly. Additionally, it should fail more gracefully if the event is something other than a pull_request.

I'll work on this in the upcoming week as best as I can.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants