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

UnhandledPromiseRejectionWarning: HttpError: Label does not exist on issues where not all labels are to be applied #32

Closed
myakura opened this issue Feb 14, 2022 · 2 comments · Fixed by #57

Comments

@myakura
Copy link
Contributor

myakura commented Feb 14, 2022

I'm trying out this action; it works but I get UnhandledPromiseRejectionWarning(s) while the action is running:

Adding labels bug to issue #11
Removing label test from issue #11
(node:1471) UnhandledPromiseRejectionWarning: HttpError: Label does not exist
at /home/runner/work/_actions/github/issue-labeler/v2.4.1/node_modules/@octokit/request/dist-node/index.js:76:23
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:1471) 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:1471) [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.

It looks like it happens when not all labels are to be applied (i.e. most cases). Suppose I have the following label-matching definitions:

test:
  - '(test)'
bug:
  - '(bug)'

When an issue is filed with a body that contains both "test" and "bug", I don't see any warning. However, when the issue only contains either "test" or "bug", I see a warning. If the body contains neither, I see two warnings.

@myakura
Copy link
Contributor Author

myakura commented Feb 14, 2022

It may be caused by calling removeLabel() inside a forEach() loop.

removeLabelItems.forEach(function (label, index) {
console.log(`Removing label ${label} from issue #${issue_number}`)
removeLabel(client, issue_number, label)
});

The removeLabel() is an async function so the call will never be catched.

@lyndseypadget
Copy link
Contributor

I use issue-labeler as the first of several steps in a GitHub action. If none of the conditions are met (meaning, the body contains none of the necessary keywords I'm looking for), then it throws this error. But because it doesn't fail the step, the following steps run anyway.

My scenario is like this:

name: "Issue Labeler"
on:
  issues:
    types: [opened]

jobs:
  triage:
    runs-on: ubuntu-latest
    steps:
    - name: If issue contains keywords, label it
      uses: github/issue-labeler@v2.5
      with:
        ...
    - name: If previous step succeeded, do the next thing
      if: ${{ success() }}
      uses: ...
      with:
        ...
    - name: If previous step succeeded, do the final thing
      if: ${{ success() }}
      uses: ...
      with:
        ...

I would expect it to fail the step. However, I can also see when it might be preferable to ignore the case where no keywords are found. This seems like a need for a configuration, where it fails the step by default (by handling the error appropriately) but the action author could override that behavior (still catch the error but suppress it with a nice message in the logs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants