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

Enhancing RepositoryContent Struct for SubmoduleGitURL support in github/repos_contents.go #2877

Closed
ArisBee opened this issue Aug 16, 2023 · 3 comments · Fixed by #2880
Closed

Comments

@ArisBee
Copy link

ArisBee commented Aug 16, 2023

Hello,

A few weeks ago, I came across an issue while running a project built atop go-github. My goal was to iterate over a GitHub Submodule folder, but it became evident that go-github might need to parse more elements from the GitHub API.

I've made an attempt to adjust this, but unfortunately, it didn't work. Here are the error logs:

allstar-756f9ccdb9-c9pzl allstar panic: runtime error: invalid memory address or nil pointer dereference                                                                                                                                                    │
│ allstar-756f9ccdb9-c9pzl allstar [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x8220f8]                                                                                                                                                    │
│ allstar-756f9ccdb9-c9pzl allstar                                                                                                                                                                                                                            │
│ allstar-756f9ccdb9-c9pzl allstar goroutine 52 [running]:                                                                                                                                                                                                    │
│ allstar-756f9ccdb9-c9pzl allstar github.com/catawiki/go-github/v50/github.(*RepositoryContent).GetContent(0xc000a7b9b0?)                                                                                                                                    │
│ allstar-756f9ccdb9-c9pzl allstar     /home/user/go/pkg/mod/github.com/catawiki/go-github/v50@v50.0.0-20230811121342-0605ae2cb9e3/github/repos_contents.go:76 +0x18                                                                                        │
│ allstar-756f9ccdb9-c9pzl allstar github.com/ossf/allstar/pkg/config.fetchConfig({0x1a79890, 0xc0006e45a0}, {0x1a731a0, 0xc000305310}, {0xc0002ec7f1, 0xd}, {0xc0002ec7b8, 0x8}, {0x16d135a, 0xc}, ...)                                                      │
│ allstar-756f9ccdb9-c9pzl allstar     /home/user/allstar/pkg/config/config.go:206 +0x331                                                                                                                                                                   │
│ allstar-756f9ccdb9-c9pzl allstar github.com/ossf/allstar/pkg/config.getAppConfigs({0x1a79890, 0xc0006e45a0}, {0x1a731a0, 0xc000305310}, {0xc0002ec7f1, 0xd}, {0xc0002ec7b8, 0x8})                                                                           │
│ allstar-756f9ccdb9-c9pzl allstar     /home/user/allstar/pkg/config/config.go:394 +0x3ed                                                                                                                                                                   │
│ allstar-756f9ccdb9-c9pzl allstar github.com/ossf/allstar/pkg/config.isBotEnabled({0x1a79890, 0xc0006e45a0}, {0x1a731a0, 0xc000305310}, {0xc0002ec7f1, 0xd}, {0xc0002ec7b8, 0x8})                                                                            │
│ allstar-756f9ccdb9-c9pzl allstar     /home/user/allstar/pkg/config/config.go:343 +0x6b                                                                                                                                                                    │
│ allstar-756f9ccdb9-c9pzl allstar github.com/ossf/allstar/pkg/config.IsBotEnabled({0x1a79890?, 0xc0006e45a0?}, 0x16d06b3?, {0xc0002ec7f1?, 0xc00028ca00?}, {0xc0002ec7b8?, 0xd?})                                                                            │
│ allstar-756f9ccdb9-c9pzl allstar     /home/user/allstar/pkg/config/config.go:339 +0x4a                                                                                                                                                                    │
│ allstar-756f9ccdb9-c9pzl allstar github.com/ossf/allstar/pkg/enforce.runPoliciesOnInstRepos({0x1a79890, 0xc0006e45a0}, {0xc0005481c0, 0x7, 0x3?}, 0xc000132180?, {0x0, 0x0})                                                                                │
│ allstar-756f9ccdb9-c9pzl allstar     /home/user/allstar/pkg/enforce/enforce.go:188 +0x112                                                                                                                                                                 │
│ allstar-756f9ccdb9-c9pzl allstar github.com/ossf/allstar/pkg/enforce.EnforceAll.func1()                                                                                                                                                                     │
│ allstar-756f9ccdb9-c9pzl allstar     /home/user/allstar/pkg/enforce/enforce.go:149 +0x1b7                                                                                                                                                                 │
│ allstar-756f9ccdb9-c9pzl allstar golang.org/x/sync/errgroup.(*Group).Go.func1()                                                                                                                                                                             │
│ allstar-756f9ccdb9-c9pzl allstar     /home/user/go/pkg/mod/golang.org/x/sync@v0.2.0/errgroup/errgroup.go:75 +0x64                                                                                                                                         │
│ allstar-756f9ccdb9-c9pzl allstar created by golang.org/x/sync/errgroup.(*Group).Go                                                                                                                                                                          │
│ allstar-756f9ccdb9-c9pzl allstar     /home/user/go/pkg/mod/golang.org/x/sync@v0.2.0/errgroup/errgroup.go:72 +0xa5       

Since I've never coded in Go before, there's a chance I might have missed something essential on my working branch. Do you perhaps have insights or suggestions?

@gmlewis
Copy link
Collaborator

gmlewis commented Aug 16, 2023

@ArisBee - from what I can tell, it looks like you did exactly the right thing... so I'm going to take a look at the upstream usage of go-github to see if there is anything unusual there...

Oh, and welcome to Go! Feel free to make PRs to improve this repo. 😄

@gmlewis
Copy link
Collaborator

gmlewis commented Aug 16, 2023

I believe I found the cause of the panic and commented here:
ossf/allstar#442 (comment)

As for go-github supporting the submodule_git_url field, we welcome PRs (and I'll leave this issue open for that). 😄

@ArisBee
Copy link
Author

ArisBee commented Aug 16, 2023

Thank you for looking into it @gmlewis, if my changes to go-github make sense then I can only focus on the changes in the other project.

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

Successfully merging a pull request may close this issue.

2 participants