Skip to content

Commit aeecad2

Browse files
committed
cloud_storage_clients: skip lexical_cast on empty strings
`parse_rest_error_response` method tries to read fields from xml response and constructs `rest_error_response`. If a field is not found or is empty then it defaults to empty string. https://github.com/redpanda-data/redpanda/blob/d3c2f00c4071c2cbce1e1babdfc2291e3c9898ba/src/v/cloud_storage_clients/s3_client.cc#L411 Google Cloud Storage gives one of these replies which we parse but the Error.Code path is not present in the response and we trip with a bad lexical cast which results in an error log line. With this commit we'll default to unknown error code in that case. We already do the same for codes we don't recognize in the operator>>. lexical_cast does not call the operator>> at all for empty strings.
1 parent 90c713a commit aeecad2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/v/cloud_storage_clients/s3_error.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,9 @@ rest_error_response::rest_error_response(
420420
std::string_view message,
421421
std::string_view request_id,
422422
std::string_view resource)
423-
: _code(boost::lexical_cast<s3_error_code>(code))
423+
: _code(
424+
code.empty() ? s3_error_code::_unknown
425+
: boost::lexical_cast<s3_error_code>(code))
424426
, _code_str(code)
425427
, _message(message)
426428
, _request_id(request_id)

0 commit comments

Comments
 (0)