Skip to content

API /repos/{owner}/{repo}/commits call error 500 on non-existent branch #31976

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

Closed
AdamMajer opened this issue Sep 4, 2024 · 2 comments · Fixed by #31977
Closed

API /repos/{owner}/{repo}/commits call error 500 on non-existent branch #31976

AdamMajer opened this issue Sep 4, 2024 · 2 comments · Fixed by #31977
Labels

Comments

@AdamMajer
Copy link
Contributor

Description

No response

Gitea Version

1.23.0+dev-460-ga366af4b7a (or 1.22)

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

This works,

curl -X 'GET' \
  'https://demo.gitea.com/api/v1/repos/bartvdbraak/blender/commits?sha=before-big-change&stat=false&verification=false&files=false&page=1' \
  -H 'accept: application/json'

but changing the sha= parameter to invalid one (eg. a branch that doesn't exist)

curl -X 'GET' \
  'https://demo.gitea.com/api/v1/repos/bartvdbraak/blender/commits?sha=not-before-big-change&stat=false&verification=false&files=false&page=1' \
  -H 'accept: application/json'

results in error 500. Expectation is we get an empty result set with result code of 200 if repository exists but branch/commit id does not.

Database

None

@AdamMajer
Copy link
Contributor Author

So, looks like any error in the sources results in error 500. Is this just temporary result at the time until a better one can be found?

204 No Content

is probably also applicable here, if no commits are found.

@AdamMajer
Copy link
Contributor Author

404 doesn't seem to match this error condition either since that is returned when repository is not there, not just a branch.

AdamMajer added a commit to AdamMajer/gitea that referenced this issue Sep 5, 2024
@lunny lunny closed this as completed in bf7ae04 Sep 5, 2024
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Dec 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant