Skip to content

Commit

Permalink
Revert "Rework error flow"
Browse files Browse the repository at this point in the history
This reverts commit 3cfa021.

Signed-off-by: Ben <belimele@redhat.com>
  • Loading branch information
Neon-White committed May 8, 2024
1 parent 3cfa021 commit f844763
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/endpoint/s3/ops/s3_get_bucket_versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function get_bucket_versions(req) {
dbg.warn('A version-id marker cannot be specified without a key marker');
throw new S3Error(S3Error.InvalidArgument);
}
const version_id_marker = s3_utils.parse_version_id(req.query['version-id-marker'], S3Error.InvalidArgumentEmptyVersionIdMarker);
const version_id_marker = s3_utils.parse_version_id_marker(req.query['version-id-marker']);
const reply = await req.object_sdk.list_object_versions({
bucket: req.params.bucket,
prefix: req.query.prefix,
Expand Down
16 changes: 13 additions & 3 deletions src/endpoint/s3/s3_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,15 +625,25 @@ function encode_uri_unless_already_encoded(uri = '') {
/**
* parse_version_id throws an error if version_id is an empty string, and returns it otherwise
* @param {string|undefined} version_id
* @param {import('./s3_errors').S3ErrorSpec} [empty_err]
*/
function parse_version_id(version_id, empty_err = S3Error.InvalidArgumentEmptyVersionId) {
function parse_version_id(version_id) {
if (version_id === '') {
throw new S3Error(empty_err);
throw new S3Error(S3Error.InvalidArgumentEmptyVersionId);
}
return version_id;
}

/**
* parse_version_id_marker throws an error if version_id_marker is an empty string, and returns it otherwise
* @param {string|undefined} version_id_marker
*/
function parse_version_id_marker(version_id_marker) {
if (version_id_marker === '') {
throw new S3Error(S3Error.InvalidArgumentEmptyVersionIdMarker);
}
return version_id_marker;
}

/**
* is_uri_already_encoded returns true if string uri is URIEncoded
* @param {string} uri
Expand Down

0 comments on commit f844763

Please sign in to comment.