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

panic when one of the PR is manually closed. #384

Closed
devcharmander opened this issue Sep 7, 2023 · 4 comments · Fixed by #385
Closed

panic when one of the PR is manually closed. #384

devcharmander opened this issue Sep 7, 2023 · 4 comments · Fixed by #385
Labels
bug Something isn't working

Comments

@devcharmander
Copy link
Contributor

Describe the bug
Platform: Github Enterprise

Issue:

When a PR is manually closed, multi-gitter run or multi-gitter status returns index out of range errors

To Reproduce
Steps to reproduce the behavior:

  • Mulitple PRs are created using multi-gitter run ...
  • Manually close a PR
  • Running mulit-gitter merge or multi-gitter run results in index out of range errors

Expected behavior
The open PRs should get merged.

Additional context
logs

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/lindell/multi-gitter/internal/scm/github.convertGraphQLPullRequest({0x64, {0x140005f6920, 0x19}, 0x1, {0x140006557c0, 0x4d}, 0x0, {{0x140005f6940, 0x1f}, {{0x140005f1420, ...}}}, ...})
	/home/runner/work/multi-gitter/multi-gitter/internal/scm/github/pullrequest.go:24 +0x208
github.com/lindell/multi-gitter/internal/scm/github.(*Github).getPullRequests(0x140005e6300?, {0x1016a4888, 0x14000118008}, {0x16f1bb058, 0x19}, {0x14000196c20, 0x32, 0x100c4d8bc?})
	/home/runner/work/multi-gitter/multi-gitter/internal/scm/github/github.go:490 +0x674
github.com/lindell/multi-gitter/internal/scm/github.(*Github).GetPullRequests(0x14000179bb8?, {0x1016a4888, 0x14000118008}, {0x16f1bb058, 0x19})
	/home/runner/work/multi-gitter/multi-gitter/internal/scm/github/github.go:386 +0x280
github.com/lindell/multi-gitter/internal/multigitter.Statuser.Statuses({{0x1016a70b0, 0x14000145560}, {0x1292721f8, 0x14000193fe0}, {0x16f1bb058, 0x19}}, {0x1016a4888?, 0x14000118008?})
	/home/runner/work/multi-gitter/multi-gitter/internal/multigitter/status.go:22 +0x5c
github.com/lindell/multi-gitter/cmd.status(0x140001ec600?, {0x140001146c0?, 0x6?, 0x6?})
	/home/runner/work/multi-gitter/multi-gitter/cmd/cmd-status.go:56 +0x108
github.com/spf13/cobra.(*Command).execute(0x140001ec600, {0x14000114660, 0x6, 0x6})
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:940 +0x5c8
github.com/spf13/cobra.(*Command).ExecuteC(0x140001ec000)
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x35c
github.com/spf13/cobra.(*Command).Execute(0x101303d14?)
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:992 +0x1c
main.main()
	/home/runner/work/multi-gitter/multi-gitter/main.go:19 +0x134

I fixed it for me by checking the length of pr.Commits.Nodes and assigning combinedStatus accordingly.
here:

combinedStatus := pr.Commits.Nodes[0].Commit.StatusCheckRollup.State

But I am not sure if that is the complete solution to this issue.
Happy to create a PR if it helps.

@devcharmander devcharmander added the bug Something isn't working label Sep 7, 2023
@lindell
Copy link
Owner

lindell commented Sep 7, 2023

Thanks for the report. This make sense if you delete the branch and just not closing it! Please do create a PR :D

@gchenuet
Copy link

Hey!
I'm facing the same situation 👍
@devcharmander can you open a PR please?

Thanks!

@devcharmander
Copy link
Contributor Author

Yes, I'll create a PR. Thanks!

@github-actions
Copy link
Contributor

Included in release v0.47.4 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants