peter-evans / create-pull-request

A GitHub action to create a pull request for changes to your repository in the actions workspace
MIT License
2.1k stars 411 forks source link

Cannot destructure property 'path' of 'undefined' as it is undefined #3329

Open AllDmeat opened 5 days ago

AllDmeat commented 5 days ago

Subject of the issue

Update from v6 to v7 broke branches autosync: Keep a branch up-to-date with another

Logs:

/usr/bin/git branch --delete --force 01e9c082-9f8a-484e-ae64-71f88826f179
Deleted branch 01e9c082-9f8a-484e-ae64-71f88826f179 (was bc810dcf65).
/usr/bin/git checkout --progress develop --
Switched to branch 'develop'
Your branch is up to date with 'origin/develop'.
Pushing pull request branch to 'origin/sync/release/10.17.0-into-develop'
/usr/bin/git stash push --include-untracked
No local changes to save
/usr/bin/git checkout --progress sync/release/10.17.0-into-develop --
Switched to branch 'sync/release/10.17.0-into-develop'
Creating tree objects for local commit 148e4896bf968684c12e6ded7e35fb6c3c6fe478
Error: Cannot destructure property 'path' of 'undefined' as it is undefined.

Only changes I've made to step is:

  1. Updated to v7
  2. Renamed token into branch-token
  3. Enabled sign-commits

Steps to reproduce

Job with v6

This works just fine:

name: Release → Develop

on:
  push:
    branches:
      - 'release/**'
  workflow_dispatch:

jobs:
  merge-release-to-develop:
    runs-on: ubuntu-latest

    timeout-minutes: 3

    env:
      BRANCH_NAME: 'sync/${{ github.ref_name }}-into-develop'

    steps:
    - uses: actions/checkout@v4
      with:
        ref: develop
        fetch-depth: 0

    - uses: tibdex/github-app-token@v2
      id: generate-token
      with:
        app_id: ${{ secrets.APP_ID }}
        private_key: ${{ secrets.APP_PRIVATE_KEY }}

    - name: Reset promotion branch
      run: |
        git fetch origin ${{ github.ref_name }}:${{ github.ref_name }}
        git reset --hard ${{ github.ref_name }}

    - name: Create Pull Request
      id: cpr
      uses: peter-evans/create-pull-request@v6
      with:
        token: ${{ steps.generate-token.outputs.token }}
        base: 'develop'
        branch: '${{ env.BRANCH_NAME }}'
        title: '${{ github.ref_name }} → develop'

    - name: Enable automerge
      if: ${{ steps.cpr.outputs.pull-request-number }}
      env:
        GH_TOKEN: ${{ steps.generate-token.outputs.token }}
      run: gh pr merge --merge --auto ${{ steps.cpr.outputs.pull-request-number }}

Job with v7

This doesn't work:

name: Release → Develop

on:
  push:
    branches:
      - 'release/**'
  workflow_dispatch:

jobs:
  merge-release-to-develop:
    runs-on: ubuntu-latest

    timeout-minutes: 3

    env:
      BRANCH_NAME: 'sync/${{ github.ref_name }}-into-develop'

    steps:
    - uses: actions/checkout@v4
      with:
        ref: develop
        fetch-depth: 0

    - uses: tibdex/github-app-token@v2
      id: generate-token
      with:
        app_id: ${{ secrets.APP_ID }}
        private_key: ${{ secrets.APP_PRIVATE_KEY }}

    - name: Reset promotion branch
      run: |
        git fetch origin ${{ github.ref_name }}:${{ github.ref_name }}
        git reset --hard ${{ github.ref_name }}

    - name: Create Pull Request
      id: cpr
      uses: peter-evans/create-pull-request@v7
      with:
        branch-token: ${{ steps.generate-token.outputs.token }}
        sign-commits: true
        base: 'develop'
        branch: '${{ env.BRANCH_NAME }}'
        title: '${{ github.ref_name }} → develop'

    - name: Enable automerge
      if: ${{ steps.cpr.outputs.pull-request-number }}
      env:
        GH_TOKEN: ${{ steps.generate-token.outputs.token }}
      run: gh pr merge --merge --auto ${{ steps.cpr.outputs.pull-request-number }}
peter-evans commented 5 days ago

Hi @AllDmeat

Thanks for reporting. I'm fairly sure this will work as it did before if you disable sign-commits. I'll investigate this and see why the commit signing code path fails in this case.

peter-evans commented 5 days ago

Are you able to provide the full log of the run? That would be very useful if you can.

Or, if there are log lines which say Skipping unexpected diff entry you can just provide those. I have a suspicion it could be related to that.

peter-evans commented 5 days ago

I've released a change in v7.0.2 / v7, which may fix it for you. Please try it and let me know.

If it doesn't fix the issue, please look for warning lines in the log which start with Skipping unexpected diff entry, and let me know the detail of the lines.

AnnAngela commented 2 days ago

Hi, we had this very same issue, and this is the gha run entry: https://github.com/MaaAssistantArknights/MaaAssistantArknights/actions/runs/10869083828

There was a report about skipping unexpected diff entry:

Skipping unexpected diff entry: :100644 100644 cb971edb7 5a6d3aa95 M CHANGELOG.md

I believed that the run used v7.0.2 since it downloaded commit d121e62763d8cc35b5fb1710e887d6e69a52d3a4 which is the commit d121e62763d8cc35b5fb1710e887d6e69a52d3a4 marked as https://github.com/peter-evans/create-pull-request/releases/tag/v7.0.2

luong-komorebi commented 1 day ago

I am experiencing the same problem. Let me know which kind of information can be helpful for the debugging process of this

I did see warnings on almost all the changes that we had

  Warning: Skipping unexpected diff entry :100644 100644 ba113843 c941067a M   <some of our files> 
  Warning: Skipping unexpected diff entry :100644 100644 ba113843 c941067a M     <some of our files> 
  Warning: Skipping unexpected diff entry  :100644 100644 ba113843 c941067a M      <some of our files> 
peter-evans commented 1 day ago

@AnnAngela @luong-komorebi Thank you both for your reports. I've identified the issue and I have a fix ready to release.

peter-evans commented 1 day ago

@AnnAngela @luong-komorebi I've released v7.0.3 / v7 to fix the issue you both reported. Thank you! ✨

I'm still going to leave this issue open. The nature of this particular feature means that there could be other related issues that also cause the same error.

For anyone experiencing this error on v7.0.3 please look for warning lines in the log which start with Skipping unexpected diff entry, and let me know the detail of the lines.

luong-komorebi commented 1 day ago

I can confirm that this issue is now resolved. @peter-evans Thank you for your prompt support

AllDmeat commented 17 hours ago

Or, if there are log lines which say Skipping unexpected diff entry you can just provide those. I have a suspicion it could be related to that.

Sorry, missed your message. There were such logs.

Updating to 7.0.3 fixed issue for me. Thanks a lot.