action icon indicating copy to clipboard operation
action copied to clipboard

Error: undefined method `to_sym' when closing PR

Open chrisft25 opened this issue 2 years ago • 4 comments

Hi! Suddenly I'm just getting this error when I close a PR (without the pullpreview label):

/app/lib/pull_preview/github_sync.rb:86:in `sync!': undefined method `to_sym' for nil:NilClass (NoMethodError)
	from /app/lib/pull_preview/github_sync.rb:26:in `run'
	from /app/bin/pullpreview:79:in `<main>'

I checked your repository and I can't see the problem

chrisft25 avatar Apr 07 '22 21:04 chrisft25

@chrisft25 is this still happening?

crohr avatar Jul 26 '22 09:07 crohr

@chrisft25 is this still happening?

Yes @crohr , this is still happening every time we close or merge a PR

chrisft25 avatar Jul 26 '22 12:07 chrisft25

We're seeing the same whenever we try to build a pull preview via a Github label. The action fails to run. Happy to provide any additional info that would be useful!

arsduo avatar Jul 30 '22 00:07 arsduo

+1 also having this problem

makeitraina avatar Aug 29 '22 02:08 makeitraina

I'm seeing this on PRs that don't have the pullpreview label. It makes an error show up in the PR, but isn't blocking. I think it's because GithubSync#guess_action_from_event may not be handling all possible cases and is returning nil. Perhaps that method should just return return :ignored at the end to handle any missing cases?

I was seemingly able to work around this by adding if: github.event.label.name == 'pullpreview' to the deploy job in the pullpreview.yml workflow config file, but obviously it's not ideal.

RyanNielson avatar Nov 04 '22 14:11 RyanNielson

@RyanNielson I'll push the fix you mention, but I'm curious: could you send me the content of your on: section from your pullpreview workflow file?

crohr avatar Nov 04 '22 15:11 crohr

And yes the filter on the label is necessary to avoid useless runs, for instance:

name: pullpreview
on:
  schedule:
    - cron: "30 0 * * *"
  push:
    branches:
      - master
  pull_request:
    types: [labeled, unlabeled, synchronize, closed, reopened]

jobs:
  deploy:
    runs-on: ubuntu-latest
    if: github.event_name == 'schedule' || github.event_name == 'push' || github.event.label.name == 'pullpreview' || contains(github.event.pull_request.labels.*.name, 'pullpreview')

crohr avatar Nov 04 '22 15:11 crohr

The fix is available in pullpreview/action@v5. Can you retest and let me know if this fixes the issue?

crohr avatar Nov 04 '22 15:11 crohr

@crohr Here ya go. Basically I only want to run on PRs with the pullpreview label, and not run otherwise.

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

Also thanks for the quick turnaround on the fix, I'll see if I can try it sometime today.

And for some more context this is what we were seeing in PRs that weren't tagged with pullpreview, and the error is related to PullPreview when you dig into it with the same exception message as this ticket was talking about. Screen Shot 2022-11-04 at 12 26 29 PM

RyanNielson avatar Nov 04 '22 15:11 RyanNielson

@crohr I just did a quick check and it seems to have sorted out my team's issues. Thanks!

RyanNielson avatar Nov 04 '22 16:11 RyanNielson