Skip to content

Commit

Permalink
Throw an appropriate exception when user provides an empty object ver…
Browse files Browse the repository at this point in the history
…sion ID (noobaa#7970)

* Throw an appropriate exception when a user provides an empty object version ID
* Only evaluate the length of `version_id` if an ID exists

Signed-off-by: Ben <[email protected]>
  • Loading branch information
Neon-White authored Apr 16, 2024
1 parent dbe81f9 commit 92f9cd5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/endpoint/s3/ops/s3_get_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ async function get_object(req, res) {
md_conditions,
encryption,
};
if (params.version_id?.length === 0) {
throw new S3Error(S3Error.InvalidArgumentEmptyVersionId);
}
if (md_params.get_from_cache) {
params.get_from_cache = true;
}
Expand Down
5 changes: 5 additions & 0 deletions src/endpoint/s3/s3_errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ S3Error.InvalidArgument = Object.freeze({
message: 'Invalid Argument',
http_code: 400,
});
S3Error.InvalidArgumentEmptyVersionId = Object.freeze({
code: 'InvalidArgument',
message: 'Version id cannot be the empty string',
http_code: 400,
});
S3Error.InvalidBucketName = Object.freeze({
code: 'InvalidBucketName',
message: 'The specified bucket is not valid.',
Expand Down

0 comments on commit 92f9cd5

Please sign in to comment.