mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 21:17:58 +08:00
fix(api): return 416 for bad upload range on PUT; fix GET upload Range at size zero (#3983)
Align closing blob upload (PUT) with the OCI Distribution Spec: invalid / out-of-order upload ranges (ErrBadUploadRange) return 416 Requested Range Not Satisfiable instead of 400, for both the final-chunk PutBlobChunk path and FinishBlobUpload. GetBlobUpload (GET upload status): fix the Range response when zero bytes have been received—send Range: 0-0 instead of Range: 0--1, consistent with a new session and the spec’s Location + Range upload status shape. Only map ErrBadBlobDigest to 400 here; do not handle ErrBadUploadRange on GET (that request carries no range; ImageStore.GetBlobUpload does not return it). Document PUT upload failures 400 and 416 in swagger; regenerate swagger artifacts. Update route tests (expect 416 on UpdateBlobUpload for ErrBadUploadRange), drop the mock-only GetBlobUpload+ErrBadUploadRange case, and assert Range: 0-0 in TestPullRange after GET on a new upload location. Fix potential panic when parsing Content-Range (index out of range) when accessing `tokens[0]`. Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
This commit is contained in:
@@ -438,12 +438,24 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "bad request",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "not found",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"416": {
|
||||
"description": "range not satisfiable",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "internal server error",
|
||||
"schema": {
|
||||
|
||||
Reference in New Issue
Block a user