Skip to content

Some API parameter parsing error #24574

Open
@painsAgains

Description

@painsAgains

Description

When I use API to access Gitea,I got some 500 response code from Gitea.But I think I should recieve 4xx code,so I think these API have some bug in design period

1. webhook-id not found

API PATH

 /admin/hooks/{id}

Method

GET,PATCH

RequestBody

{}

URL

http://localhost:3000/api/v1/admin/hooks/14

Response code and message

code: 500 message:webhook does not exist [id: 14]

Problem description

In fact, I think that when I access a non-existent webhook-id, I should receive a 4xx response code, e.g. 404 instead of 500

2. last_read_at parameter parsing error

API PATH

 /notifications

Method

PUT

RequestBody

""

URL

http://localhost:3000/api/v1/notifications?last_read_at\u003d1682567431888

Response code and message

code: 500 message:parsing time \\\"1682567431888\\\" as \\\"2006-01-02T15:04:05Z07:00\\\": cannot parse \\\"567431888\\\" as \\\"-\\\"\",\"url\":\"http://localhost:3000/api/swagger"

Problem description

I think Gitea should return me a 4xx error when I enter an incorrect parameter format, or forbid me to enter parameters in this format

3. Usename inconsistency

API PATH

 /admin/users/{username}/orgs

Method

POST

RequestBody

{"location": "fuzzstring", "username": "fake_name"}"

URL

http://localhost:3000/api/v1/admin/users/real_name/orgs

Response code and message

 user is not allowed to create organizations

Problem description

This 500 error occurs when the username parameter I entered in the requestBody does not match the username parameter in the url path, it is worth mentioning that the username in the url path is actual, while the username parameter in the requestBody is fictitious.I think I should have received a 4xx response code, or a critical check of the parameters

Gitea Version

1.19.1

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?

I build Gitea by using https://dl.gitea.com/gitea/1.19.1/gitea-1.19.1-linux-amd64

Database

PostgreSQL

Metadata

Metadata

Assignees

No one assigned

    Labels

    modifies/apiThis PR adds API routes or modifies themtopic/apiConcerns mainly the APItype/bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions