Merge pull request #1729 from versity/sis/versions-query-with-key

fix: adds an error route for ?versions subresource with key
This commit is contained in:
Ben McClelland
2026-01-03 20:52:09 -08:00
committed by GitHub
4 changed files with 31 additions and 0 deletions
+6
View File
@@ -1048,6 +1048,12 @@ func (sa *S3ApiRouter) Init(app *fiber.App, be backend.Backend, iam auth.IAMServ
controllers.ProcessHandlers(ctrl.HandleErrorRoute(s3err.GetAPIError(s3err.ErrGetUploadsWithKey)), metrics.ActionUndetected, services), controllers.ProcessHandlers(ctrl.HandleErrorRoute(s3err.GetAPIError(s3err.ErrGetUploadsWithKey)), metrics.ActionUndetected, services),
) )
// object operation with '?versions' is rejected with a specific error
objectRouter.Get("",
middlewares.MatchQueryArgs("versions"),
controllers.ProcessHandlers(ctrl.HandleErrorRoute(s3err.GetAPIError(s3err.ErrVersionsWithKey)), metrics.ActionUndetected, services),
)
// object GET operation is not allowed with copy source // object GET operation is not allowed with copy source
objectRouter.Get("/", objectRouter.Get("/",
middlewares.MatchHeader("X-Amz-Copy-Source"), middlewares.MatchHeader("X-Amz-Copy-Source"),
+6
View File
@@ -127,6 +127,7 @@ const (
ErrRequestNotReadyYet ErrRequestNotReadyYet
ErrMissingDateHeader ErrMissingDateHeader
ErrGetUploadsWithKey ErrGetUploadsWithKey
ErrVersionsWithKey
ErrCopySourceNotAllowed ErrCopySourceNotAllowed
ErrInvalidRequest ErrInvalidRequest
ErrAuthNotSetup ErrAuthNotSetup
@@ -542,6 +543,11 @@ var errorCodeResponse = map[ErrorCode]APIError{
Description: "Key is not expected for the GET method ?uploads subresource", Description: "Key is not expected for the GET method ?uploads subresource",
HTTPStatusCode: http.StatusBadRequest, HTTPStatusCode: http.StatusBadRequest,
}, },
ErrVersionsWithKey: {
Code: "InvalidRequest",
Description: "There is no such thing as the ?versions sub-resource for a key",
HTTPStatusCode: http.StatusBadRequest,
},
ErrCopySourceNotAllowed: { ErrCopySourceNotAllowed: {
Code: "InvalidArgument", Code: "InvalidArgument",
Description: "You can only specify a copy source header for copy requests.", Description: "You can only specify a copy source header for copy requests.",
+17
View File
@@ -189,6 +189,23 @@ func RouterCopySourceNotAllowed(s *S3Conf) error {
}) })
} }
func RouterListVersionsWithKey(s *S3Conf) error {
testName := "RouterListVersionsWithKey"
return actionHandlerNoSetup(s, testName, func(s3client *s3.Client, bucket string) error {
req, err := http.NewRequest(http.MethodGet, s.endpoint+"/bucket/object?versions", nil)
if err != nil {
return err
}
resp, err := s.httpClient.Do(req)
if err != nil {
return err
}
return checkHTTPResponseApiErr(resp, s3err.GetAPIError(s3err.ErrVersionsWithKey))
})
}
// CORS middleware tests // CORS middleware tests
func CORSMiddleware_invalid_method(s *S3Conf) error { func CORSMiddleware_invalid_method(s *S3Conf) error {
testName := "CORSMiddleware_invalid_method" testName := "CORSMiddleware_invalid_method"
+2
View File
@@ -1094,6 +1094,7 @@ func TestRouter(ts *TestState) {
ts.Run(RouterPUTObjectOnlyUploadId) ts.Run(RouterPUTObjectOnlyUploadId)
ts.Run(RouterGetUploadsWithKey) ts.Run(RouterGetUploadsWithKey)
ts.Run(RouterCopySourceNotAllowed) ts.Run(RouterCopySourceNotAllowed)
ts.Run(RouterListVersionsWithKey)
} }
func TestUnsignedStreaminPayloadTrailer(ts *TestState) { func TestUnsignedStreaminPayloadTrailer(ts *TestState) {
@@ -1776,6 +1777,7 @@ func GetIntTests() IntTests {
"RouterPUTObjectOnlyUploadId": RouterPUTObjectOnlyUploadId, "RouterPUTObjectOnlyUploadId": RouterPUTObjectOnlyUploadId,
"RouterGetUploadsWithKey": RouterGetUploadsWithKey, "RouterGetUploadsWithKey": RouterGetUploadsWithKey,
"RouterCopySourceNotAllowed": RouterCopySourceNotAllowed, "RouterCopySourceNotAllowed": RouterCopySourceNotAllowed,
"RouterListVersionsWithKey": RouterListVersionsWithKey,
"UnsignedStreaminPayloadTrailer_malformed_trailer": UnsignedStreaminPayloadTrailer_malformed_trailer, "UnsignedStreaminPayloadTrailer_malformed_trailer": UnsignedStreaminPayloadTrailer_malformed_trailer,
"UnsignedStreamingPayloadTrailer_missing_invalid_dec_content_length": UnsignedStreamingPayloadTrailer_missing_invalid_dec_content_length, "UnsignedStreamingPayloadTrailer_missing_invalid_dec_content_length": UnsignedStreamingPayloadTrailer_missing_invalid_dec_content_length,
"UnsignedStreamingPayloadTrailer_invalid_trailing_checksum": UnsignedStreamingPayloadTrailer_invalid_trailing_checksum, "UnsignedStreamingPayloadTrailer_invalid_trailing_checksum": UnsignedStreamingPayloadTrailer_invalid_trailing_checksum,