fix(api): use not found status code when appropriate (#6885)
Some checks are pending
/ release (push) Waiting to run
testing / test-e2e (push) Blocked by required conditions
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions

- Use a 404 error when the issue not found instead of returning an internal server error.
- Resolves #4005
- Added integration test.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6885
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: ThomasBoom89 <thomasboom89@noreply.codeberg.org>
Co-committed-by: ThomasBoom89 <thomasboom89@noreply.codeberg.org>
This commit is contained in:
ThomasBoom89 2025-02-12 20:18:33 +00:00 committed by Gusted
parent ab69057327
commit 5feca875ea
4 changed files with 119 additions and 8 deletions

View file

@ -8667,6 +8667,12 @@
},
"404": {
"$ref": "#/responses/notFound"
},
"422": {
"$ref": "#/responses/validationError"
},
"500": {
"$ref": "#/responses/internalServerError"
}
}
}
@ -8720,6 +8726,9 @@
},
"404": {
"$ref": "#/responses/notFound"
},
"500": {
"$ref": "#/responses/internalServerError"
}
}
},
@ -8760,8 +8769,8 @@
"403": {
"$ref": "#/responses/forbidden"
},
"404": {
"$ref": "#/responses/notFound"
"500": {
"$ref": "#/responses/internalServerError"
}
}
},
@ -8823,6 +8832,9 @@
},
"423": {
"$ref": "#/responses/repoArchivedError"
},
"500": {
"$ref": "#/responses/internalServerError"
}
}
}
@ -9959,6 +9971,12 @@
},
"404": {
"$ref": "#/responses/notFound"
},
"422": {
"$ref": "#/responses/validationError"
},
"500": {
"$ref": "#/responses/internalServerError"
}
}
},
@ -10017,6 +10035,9 @@
},
"423": {
"$ref": "#/responses/repoArchivedError"
},
"500": {
"$ref": "#/responses/internalServerError"
}
}
}
@ -10067,8 +10088,8 @@
"403": {
"$ref": "#/responses/forbidden"
},
"404": {
"$ref": "#/responses/notFound"
"500": {
"$ref": "#/responses/internalServerError"
}
}
},
@ -10135,6 +10156,9 @@
},
"404": {
"$ref": "#/responses/notFound"
},
"500": {
"$ref": "#/responses/internalServerError"
}
}
}
@ -11386,6 +11410,12 @@
},
"404": {
"$ref": "#/responses/notFound"
},
"422": {
"$ref": "#/responses/validationError"
},
"500": {
"$ref": "#/responses/internalServerError"
}
}
}
@ -20453,6 +20483,20 @@
},
"x-go-package": "code.gitea.io/gitea/services/context"
},
"APIInternalServerError": {
"type": "object",
"properties": {
"message": {
"type": "string",
"x-go-name": "Message"
},
"url": {
"type": "string",
"x-go-name": "URL"
}
},
"x-go-package": "code.gitea.io/gitea/services/context"
},
"APIInvalidTopicsError": {
"type": "object",
"properties": {
@ -29165,6 +29209,12 @@
"$ref": "#/definitions/APIForbiddenError"
}
},
"internalServerError": {
"description": "APIInternalServerError is an error that is raised when an internal server error occurs",
"schema": {
"$ref": "#/definitions/APIInternalServerError"
}
},
"invalidTopicsError": {
"description": "APIInvalidTopicsError is error format response to invalid topics",
"schema": {