lakeFS
lakeFS copied to clipboard
Inconsistency between the response status codes defined in the Swagger spec and those used in our codebase
What happened?
Issue
We have a broad inconsistency between the response status codes defined in the Swagger spec and those used in our codebase.
Description
In status.go (from the http package), several status codes used in our codebase are not declared at all in the Swagger spec. Example: 503 StatusServiceUnavailablee, 300 StatusMultipleChoices, and others.
On the other hand, these are the only non-2xx response status codes defined in the Swagger file:
302: Successfully got token 304: Content not modified 400: BadRequest / ValidationError 401: Unauthorized 403: Forbidden 404: NotFound / NotFoundOrNoACL 409: Conflict 410: Object expired 412: Precondition failed 416: Requested range not satisfiable 420: Too many requests 500: Server error (default) 501: Not implemented
Also some of these are defined using components.responses (404 NotFoundOrNoACL) in the Swagger spec, while others like 420 are defined inline without a shared response schema. for example:
404:
$ref: "#/components/responses/NotFoundOrNoACL"
NotFoundOrNoACL:
description: Group not found, or group found but has no ACL
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorNoACL"
420:
description: too many requests
There are also duplicate status codes with different descriptions (400 and 404).
Additional inconsistencies:
- Same as with 503 - we return 423 StatusLocked, but it’s not mentioned in Swagger:
case errors.Is(err, graveler.ErrTooManyTries):
log.Debug("Retried too many times")
cb(w, r, http.StatusLocked, "Too many attempts, try again later")
- We return 410 StatusGone with the message “No data”, but in Swagger it’s described as “object expired”:
case errors.Is(err, block.ErrDataNotFound):
log.Debug("No data")
cb(w, r, http.StatusGone, "No data")
Expected behavior
No response
lakeFS version
No response
How lakeFS is installed
No response
Affected clients
No response
Relevant log output
Contact details
No response