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

Action Fails to update existing PRs on Private repos #2823

Closed
livinlefevreloca opened this issue Mar 15, 2024 · 2 comments
Closed

Action Fails to update existing PRs on Private repos #2823

livinlefevreloca opened this issue Mar 15, 2024 · 2 comments

Comments

@livinlefevreloca
Copy link

livinlefevreloca commented Mar 15, 2024

Subject of the issue

Getting the following error on when my workflow tries to use the action to update an existing PR on private repositories

  Attempting creation of pull request
  A pull request already exists for meetalbert:main-rebase/notifications_dbrouter_on_7811
  Fetching existing pull request
  Attempting update of pull request
  Error: Cannot read properties of undefined (reading 'number')

Describe your issue here.

Starting on 2024-03-09 I started seeing the above error in one of our workflows where the action fails to update existing pull requests. We were using version v4.0.0 but I upgraded to the latest version of the action and the problem persists. We have not changed anything in the workflow that started failing in over a year.

The action appears to be getting an empty list back when querying the github API for pull requests here. Then when indexing into the list here it gets undefined back.

Steps to reproduce

I was able to reproduce the empty list result using the github API and curl but for a private repos only

curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <token>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/OWNER/PRIVATE_REPO/pulls\?state\=open\&base\=master\&head\=OWNER:BRANCH

^^ Will return empty list

It seems to be alleviated if you remove the OWNER from the head parameter

curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <token>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/OWNER/PRIVATE_REPO/pulls\?state\=open\&base\=master\&head\=BRANCH

For public repos it seems to work either way

curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <token>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/livinlefevreloca/va-rs-int/pulls\?state\=open\&base\=master\&head\=livinlefevreloca:add-read-me
curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <token>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/livinlefevreloca/va-rs-int/pulls\?state\=open\&base\=master\&head\=add-read-me

If this issue is describing a possible bug please provide (or link to) your GitHub Actions workflow.

Unfortunatley I cannot provide the full workflow here is out use if the action within the workflow though. Not sure if that will be helpful or not

    - name: Create Pull Request for DBT
      uses: peter-evans/create-pull-request@v6
      with:
        path: albert-dbt-analytics-transforms
        token: ${{ secrets.REPO_ACCESS_TOKEN_DEVOPS }}
        branch: main-${{ github.event.client_payload.branch }}
        body: Generated dbt changes from ${{ github.event.client_payload.pr_link }}
        delete-branch: true
        base: master
        title: DBT codegen changes for main
        reviewers: livinlefevreloca
        commit-message: DBT changes from ${{ github.event.client_payload.commit }}
    - name: Create Pull Request for Looker
      uses: peter-evans/create-pull-request@v6
      with:
        path: looker
        token: ${{ secrets.REPO_ACCESS_TOKEN_DEVOPS }}
        branch: main-${{ github.event.client_payload.branch }}
        body: Generated looker changes from ${{ github.event.client_payload.pr_link }}
        delete-branch: true
        base: master
        title: Looker codegen changes for main
        reviewers: livinlefevreloca
        commit-message: Looker changes from ${{ github.event.client_payload.commit }}
@peter-evans
Copy link
Owner

Hi @livinlefevreloca

This should be fixed in v6 now. The fix was released in v6.0.1: https://github.com/peter-evans/create-pull-request/releases/tag/v6.0.1

Also see #2790

Can you confirm that you can reproduce this with v6 currently?

@livinlefevreloca
Copy link
Author

Hi @peter-evans,

You are correct that did fix it. In my original test I did not merge the workflow into the master since the workflow I was testing was pre-merge. Thanks for the help!

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

2 participants