gitbutlerapp / gitbutler

The GitButler version control client, backed by Git, powered by Tauri/Rust/Svelte
https://gitbutler.com
Other
12.37k stars 486 forks source link

"head invalid" creating PR #4459

Open rbtcollins opened 1 month ago

rbtcollins commented 1 month ago

Version

0.12.13

Operating System

Windows

Distribution Method

msi (Windows)

Describe the issue

Clicking 'Create PR' fails. Pushing does not seem to change anything. image

How to reproduce

Download gitbutler login to github and to git butler select an existing repo with two remotes: origin and upstream make a commit to the workspace, click on 'create pr'.

Expected behavior

The PR should be created

Relevant log output

board:1 [Intervention] Images loaded lazily and replaced with placeholders. Load events are deferred. See https://go.microsoft.com/fwlink/?linkid=2048113
board:1  Tracking Prevention blocked access to storage for https://www.gravatar.com/avatar/d4a7fc39d443767abbe16fc219bf3910?s=100&r=g&d=retro.
board:1  Tracking Prevention blocked access to storage for https://www.gravatar.com/avatar/d4a7fc39d443767abbe16fc219bf3910?s=100&r=g&d=retro.
api.github.com/repos/testing-cabal/testrepository/pulls:1 

        Failed to load resource: the server responded with a status of 422 ()
api.github.com/repos/testing-cabal/testrepository/pulls:1 

        Failed to load resource: the server responded with a status of 422 ()
api.github.com/repos/testing-cabal/testrepository/pulls:1 

        Failed to load resource: the server responded with a status of 422 ()
api.github.com/repos/testing-cabal/testrepository/pulls:1 

        Failed to load resource: the server responded with a status of 422 ()
user.Dkod6d5m.js:4  HttpError: Validation Failed: {"resource":"PullRequest","field":"head","code":"invalid"} - https://docs.github.com/rest/pulls/pulls#create-a-pull-request
    at unsubscribe.D-43Dc8Z.js:6:8478
    at async o (3.BK1VXHPD.js:212:6696)
    at async Ba.createPr (3.BK1VXHPD.js:212:6899)
    at async ht (14.CtP4KFRF.js:481:1041)
    at async Object.click (14.CtP4KFRF.js:482:2155)
(anonymous) @ user.Dkod6d5m.js:4
2user.Dkod6d5m.js:4 Set remote branch name
api.github.com/repos/testing-cabal/testrepository/pulls:1 

        Failed to load resource: the server responded with a status of 422 ()
api.github.com/repos/testing-cabal/testrepository/pulls:1 

        Failed to load resource: the server responded with a status of 422 ()
api.github.com/repos/testing-cabal/testrepository/pulls:1 

        Failed to load resource: the server responded with a status of 422 ()
api.github.com/repos/testing-cabal/testrepository/pulls:1 

        Failed to load resource: the server responded with a status of 422 ()
user.Dkod6d5m.js:4  HttpError: Validation Failed: {"resource":"PullRequest","field":"head","code":"invalid"} - https://docs.github.com/rest/pulls/pulls#create-a-pull-request
    at unsubscribe.D-43Dc8Z.js:6:8478
    at async o (3.BK1VXHPD.js:212:6696)
    at async Ba.createPr (3.BK1VXHPD.js:212:6899)
    at async ht (14.CtP4KFRF.js:481:1041)
    at async Object.click (14.CtP4KFRF.js:482:2155)
(anonymous) @ user.Dkod6d5m.js:4
api.github.com/repos/testing-cabal/testrepository/pulls:1 

        Failed to load resource: the server responded with a status of 422 ()
api.github.com/repos/testing-cabal/testrepository/pulls:1 

        Failed to load resource: the server responded with a status of 422 ()
api.github.com/repos/testing-cabal/testrepository/pulls:1 

        Failed to load resource: the server responded with a status of 422 ()
api.github.com/repos/testing-cabal/testrepository/pulls:1 

        Failed to load resource: the server responded with a status of 422 ()
user.Dkod6d5m.js:4  HttpError: Validation Failed: {"resource":"PullRequest","field":"head","code":"invalid"} - https://docs.github.com/rest/pulls/pulls#create-a-pull-request
    at unsubscribe.D-43Dc8Z.js:6:8478
    at async o (3.BK1VXHPD.js:212:6696)
    at async Ba.createPr (3.BK1VXHPD.js:212:6899)
    at async ht (14.CtP4KFRF.js:481:1041)
    at async Object.click (14.CtP4KFRF.js:482:2155)
(anonymous) @ user.Dkod6d5m.js:4
api.github.com/repos/testing-cabal/testrepository/pulls:1 

        Failed to load resource: the server responded with a status of 422 ()
api.github.com/repos/testing-cabal/testrepository/pulls:1 

        Failed to load resource: the server responded with a status of 422 ()
api.github.com/repos/testing-cabal/testrepository/pulls:1 

        Failed to load resource: the server responded with a status of 422 ()
api.github.com/repos/testing-cabal/testrepository/pulls:1 

        Failed to load resource: the server responded with a status of 422 ()
user.Dkod6d5m.js:4  HttpError: Validation Failed: {"resource":"PullRequest","field":"head","code":"invalid"} - https://docs.github.com/rest/pulls/pulls#create-a-pull-request
    at unsubscribe.D-43Dc8Z.js:6:8478
    at async o (3.BK1VXHPD.js:212:6696)
    at async Ba.createPr (3.BK1VXHPD.js:212:6899)
    at async ht (14.CtP4KFRF.js:481:1041)
Byron commented 1 month ago

Thanks for reporting the issue so comprehensively!

When trying the same on a small private repository on GitHub, it did work as expected. I was able to push and create a PR afterwards. Maybe it mattered that I pushed first though, so I redid the operation without pushing first, but it seems GitButler manages this situation correctly as well.

Interpreting the error code, it looks like the commit at which the PR was supposed to be created was considered invalid. This makes me think that maybe the branch to create the PR from didn't exist, somehow. To validate this, I renamed the remote branch to a name that wasn't pushed yet and created a PR right away. It worked just like before.

Thus I am a little bit puzzled as to what happens here.

Looking at the logs further also seems to indicate that loading the existing PRs fails with a similar status code.

In the end, I wouldn't even know what to ask as follow-up question, unfortunately, but maybe the above interpretation attempts help someone else to figure out further debugging steps.

rbtcollins commented 1 month ago

Possibly adding some more telemetry, or a debug mode, might help. I'd be happy to run a build that did that.

For now though, I won't have more to add - because of the separate #2513 I'm switching to stacked-git for daily use.