s3: return NoSuchVersion (not NoSuchKey) for a missing versionId (#9749)

GET/HEAD object with an explicit versionId that does not exist returned
NoSuchKey. AWS S3 returns NoSuchVersion (404) for this case; tools that
distinguish "key gone" from "this version gone" rely on that code.

Add the ErrNoSuchVersion error code and use it on the GET and HEAD
specific-version lookups. Only a genuine not-found maps to NoSuchVersion;
a transient or internal filer error now maps to InternalError (500)
instead of a misleading 404. getSpecificObjectVersion wraps its lookup
error with %w so callers can detect filer_pb.ErrNotFound.
This commit is contained in:
Chris Lu authored and GitHub committed 2026-05-30 21:09:53 -07:00
1 parent 7c5ca01027
commit 0e35235908
3 files changed
+18 -4

No files matched your search

+6
View File
@@ -57,6 +57,7 @@ const (
ErrNoSuchCORSConfiguration
ErrNoSuchLifecycleConfiguration
ErrNoSuchKey
ErrNoSuchVersion
ErrNoSuchUpload
ErrInvalidBucketName
ErrInvalidBucketState
@@ -281,6 +282,11 @@ var errorCodeResponse = map[ErrorCode]APIError{
Description: "The specified key does not exist.",
HTTPStatusCode: http.StatusNotFound,
},
ErrNoSuchVersion: {
Code: "NoSuchVersion",
Description: "The specified version does not exist.",
HTTPStatusCode: http.StatusNotFound,
},
ErrNoSuchUpload: {
Code: "NoSuchUpload",
Description: "The specified multipart upload does not exist. The upload ID may be invalid, or the upload may have been aborted or completed.",