changed-files icon indicating copy to clipboard operation
changed-files copied to clipboard

[error]Could not get pull request from context, exiting

Open ravikp7 opened this issue 4 years ago • 8 comments

Hi @futuratrepadeira ! Thanks for this nifty action. I'm running into this issue.

My workflow looks like this:

- name: Changed Files Exporter
        id: get_file_changes
        uses: futuratrepadeira/[email protected]
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          pattern: '^.*\.(ts|tsx)$'

Inspecting the code, I see it failing at the below line.

https://github.com/futuratrepadeira/changed-files/blob/ca328ebf8ca65f94258677cea8478f0094d76a8e/src/main.ts#L100

What could be a possible reason? Can I debug this locally?

Let me know if you need more debug info.

ravikp7 avatar Aug 31 '20 08:08 ravikp7

Hi @ravikp7, can you tell me on what event you're using the action? If you're not using it with pull_request events, then you have to specify the pr-number input.

duarten avatar Aug 31 '20 16:08 duarten

Hi @ravikp7, can you tell me on what event you're using the action? If you're not using it with pull_request events, then you have to specify the pr-number input.

I'm using it for the pull_request event

ravikp7 avatar Aug 31 '20 16:08 ravikp7

Hum.. that means accessing github.context.payload.pull_request resulted in an undefined value. The event is supposed to be stored in workflow/event.json/GITHUB_EVENT_PATH. Can your action be doing something that changes this?

Maybe this changed at some point, in which case I would recommend you try to run the action at v3.3.0. Unfortunately, there's no good way to debug this issue locally :/

duarten avatar Aug 31 '20 17:08 duarten

I see the same issue with v3.3.0 when using

     - name: Changed Files Exporter
        id: changed-files
        uses: futuratrepadeira/[email protected]
        with:
          repo-token: '${{ secrets.GITHUB_TOKEN }}'          
          pattern: '^.*\.(md|markdown)$'
          result-encoding: 'string'

The error I get looks like the following:

Run futuratrepadeira/[email protected]
  with:
    repo-token: ***
    pattern: ^.*\.(md|markdown)$
    result-encoding: string
Error: Could not get pull request from context, exiting

According to https://github.com/actions/checkout/issues/136, I also tried to set

- uses: actions/checkout@v2
   with:
      ref: main

a the checkout step I run before.

aheil avatar Oct 30 '20 22:10 aheil

@aheil is this something that happened once, or happens frequently? If the former, is anything special about that PR that you can think of?

duarten avatar Oct 31 '20 04:10 duarten

It happens frequently, I just tried another Action were I also have to pass the GITHUB_TOKEN. Haven't changed anything else. I do not encounter any problems then.
If I can prived any further information, please let me know.

aheil avatar Oct 31 '20 19:10 aheil

I get the error if my config includes the push:

on:
  pull_request:
    branches:
      - develop
    paths:
      - '**.py'
  push:
    paths:
      - '**.py'

No error for pull_request event. Would it be possible to add support for just pushes?

roman-parkhunovskyi avatar Nov 10 '20 11:11 roman-parkhunovskyi

There's currently some support for push: you can specify the pr-number input. Adding native support for push shouldn't be too hard.

duarten avatar Nov 10 '20 15:11 duarten