Skip to content

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

Closed
@AdamMajer

Description

@AdamMajer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions