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

Workflow failure: Could not resolve to a PullRequest with the number of 0 #392

Closed
garaujodev opened this issue Sep 6, 2023 · 7 comments

Comments

@garaujodev
Copy link

I'm getting consecutive failures in the workflow. This is my output:

Checking GitHub labels ...
2023/09/06 12:23:33 Error that we cannot handle, Could not resolve to a PullRequest with the number of 0.

My workflow file

name: Label checker
on:
  pull_request:
    types:
      - opened
      - reopened
      - edited
      - synchronize
      - labeled
      - unlabeled

jobs:
  check_labels:
    name: Check labels
    runs-on: ubuntu-latest
    steps:
      - uses: docker://agilepathway/pull-request-label-checker:latest
        with:
          one_of: fix,feature,build,documentation,refactor,chore,style,test,performance,revert
          none_of: blocked
          repo_token: ${{ secrets.GITHUB_TOKEN }}

Any ideas?

@johnboyes
Copy link
Contributor

Hi @garaujodev, thanks for raising this. I suspect this was inadvertently caused by v1.5.0 which was released last week. I'm about to go on holiday for a week, so as I don't have time to find the proper fix before I go I'll revert that change in a new release, working on that right now.

johnboyes added a commit that referenced this issue Sep 6, 2023
This reverts commit 149b0c2
("Use PR number from pull_request object").

Reverting [as this seems to have caused an error in some scenarios][1].

[1]: #392
@johnboyes johnboyes mentioned this issue Sep 6, 2023
johnboyes added a commit that referenced this issue Sep 6, 2023
This reverts commit 149b0c2
("Use PR number from pull_request object").

Reverting [as this seems to have caused an error in some scenarios][1].

[1]: #392
@johnboyes
Copy link
Contributor

Done, I have created a new release v1.5.4 which reverts the suspect v1.5.0 change. @garaujodev please confirm that this has fixed things for you, thanks.

@piotrekkr
Copy link
Contributor

piotrekkr commented Sep 7, 2023

@garaujodev Can you tell what kind of event type it is exactly that is generating this error? It works for me for pull_request_review and also pull_request.

image

My workflow looks like this:

name: Check labels

on:
  pull_request:
    types: [opened, synchronize, reopened, labeled, unlabeled]

jobs:
  check-labels:
    name: Check PR labels
    runs-on: ubuntu-22.04
    steps:
      - name: Golden master label validation
        uses: docker://agilepathway/pull-request-label-checker:v1.5.0
        with:
          one_of: golden-master-validated
          none_of: do-not-merge
          repo_token: ${{ secrets.GITHUB_TOKEN }}

//EDIT

Also checked with latest version and it works too.

// EDIT 2

@garaujodev Can you try using uses: docker://agilepathway/pull-request-label-checker:v1.5.0@sha256:5745b51639f30321637979ecf0482dab3a35ec027c398ba958bdfde475b97346 and test if it works?

@garaujodev
Copy link
Author

Hello guys! Thanks for the quick support!

I tried to use the latest version, but the problem still occurs. I forget to mention here in my configuration file, but I have other trigger:

name: Label checker
on:
  workflow_run:
    workflows: ['Release Drafter']
    types:
      - completed
  pull_request:
    types:
      - opened
      - reopened
      - edited
      - synchronize
      - labeled
      - unlabeled

jobs:
  check_labels:
    name: Check labels
    runs-on: ubuntu-latest
    steps:
      - uses: docker://agilepathway/pull-request-label-checker:latest
        with:
          one_of: fix,feature,build,documentation,refactor,chore,style,test,performance,revert
          none_of: blocked
          repo_token: ${{ secrets.GITHUB_TOKEN }}

Sorry for didn't mention this part.

After an investigation, I noticed that the problem happens due to this trigger action (workflow_run), via the pull_request trigger works perfectly. Sounds like a problem in my workflow, I'll remove the workflow_run trigger and keep you updated.

@piotrekkr
Copy link
Contributor

@garaujodev Thanks for reply. I think workflow_run event may not provide accurate PR data. Here is event payload described and I can see it has pull_requests key containing array of pull requests. workflow_run event may be triggered by variety of events and may or may not contain pull_requests key in payload for example when triggering workflow run was started by push event on main branch. It would fail even without my change with pull_request_review fix.

In theory this action could try to check:

  • if exist: github.event.pull_request then use this
  • if exist: github.event.workflow_run.pull_requests[0] then use this

But this seems a little hackish.

If this label check should only work with pull requests events then you should use

on:
  pull_request:
    ...

@johnboyes
Copy link
Contributor

Thanks for looking into this so thoroughly, @piotrekkr, and for providing the additional info above, @garaujodev. I agree with @piotrekkr's proposal to always use the pull_request event and never use the workflow_run event when using this label checker. If that sounds ok to you both then the only action I now need to take is a new release reinstating the functionality that I reverted as a precaution last week.

johnboyes added a commit that referenced this issue Sep 13, 2023
This reverts commit f7377ad.

That commit reverted #386 as a precautionary measure, while
[investigating a potential bug][1].  It turns out
[that there was no bug][2], though, so this commit reverts that revert.

[1]: #392
[2]: #392 (comment)
johnboyes added a commit that referenced this issue Sep 13, 2023
This reverts commit f7377ad.

That commit reverted #386 as a precautionary measure, while
[investigating a potential bug][1].  It turns out
[that there was no bug][2], though, so this commit reverts that revert.

[1]: #392
[2]: #392 (comment)
@johnboyes
Copy link
Contributor

the only action I now need to take is a new release reinstating the functionality that I reverted as a precaution last week.

This is now done, in #400. I'll close this issue now, thanks again to both of you, @piotrekkr and @garaujodev for the thorough investigation 🙏🏻

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

No branches or pull requests

3 participants