-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
On tag/branch-exist check, dont panic if repo is nil #21787
Conversation
It's better to do the check out of the method. |
you mean check what func did call this in the first place? |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whilst the repo should not be nil I suspect it may just be easier to have this kind of NPE protection.
@6543 the logging surrounding this PANIC would have been helpful as
Would have written a start event at line 122 and an end event in its defer. However, we can see
this is related to
The context of which is:
And we see that the gitRepo should not be nil here. So I don't understand how this can happen. |
right! but it did :/ |
|
It would still be really useful to figure out how ctx.Repo.GitRepo was nil here. I have a feeling that the there was an error higher up that didn't get handled properly. It would be really helpful to get the context for the logs i.e check if there were any other log lines for [636fd44c-60] |
Aha! I have understood the problem:
Here You are running the API GetBranch call on an "empty" repository. Now, I have a feeling that this code should be handling the error condition itself but maybe I'm wrong and we want the API endpoints to have to check for empty repos themselves BUT I would have thought that if an API wanted to deal with empty repos it would indicate that by using Following this reasoning this PR is not really correct and instead we should be getting the GetBranch endpoint to check for empty OR make ReferencesGitRepo error out if there is an empty repo. |
make lgtm work |
* giteaofficial/main: Ensure that Chinese punctuation is not ambiguous when locale is Chinese (go-gitea#22019) Use GhostUser if needed for TrackedTimes (go-gitea#22021) Add dumb-init to rootless docker (go-gitea#21775) On tag/branch-exist check, dont panic if repo is nil (go-gitea#21787) Fix ListBranches to handle empty case (go-gitea#21921) fix(web): reduce page jitter on browsers that support overlay scrollbar (go-gitea#21850) [skip ci] Updated licenses and gitignores Do not emit ambiguous character warning on rendered pages (go-gitea#22016)
fix a panic found in gitea logs