Skip to content

Commit 6588f9a

Browse files
authored
Only retry-able S3 error code will be converted to CRT error code (#433)
1 parent bc404f4 commit 6588f9a

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

include/aws/s3/private/s3_util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,9 @@ void aws_s3_calculate_auto_ranged_get_part_range(
299299
uint64_t *out_part_range_start,
300300
uint64_t *out_part_range_end);
301301

302-
/* Match the S3 error code to CRT error code, return AWS_ERROR_UNKNOWN when not matched */
302+
/* Match the retry-able S3 error code to CRT error code, return AWS_ERROR_UNKNOWN when not matched. */
303303
AWS_S3_API
304-
int aws_s3_crt_error_code_from_server_error_code_string(struct aws_byte_cursor error_code_string);
304+
int aws_s3_crt_error_code_from_recoverable_server_error_code_string(struct aws_byte_cursor error_code_string);
305305

306306
AWS_S3_API
307307
void aws_s3_request_finish_up_metrics_synced(struct aws_s3_request *request, struct aws_s3_meta_request *meta_request);

source/s3_meta_request.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,13 @@ static bool s_should_check_for_error_despite_200_OK(const struct aws_s3_request
15041504
return true;
15051505
}
15061506

1507+
/**
1508+
* Check the response detail, returns:
1509+
* - AWS_ERROR_SUCCESS for successfully response
1510+
* - AWS_ERROR_S3_NON_RECOVERABLE_ASYNC_ERROR 200 response with error in the body that is non-recoverable
1511+
* - AWS_ERROR_S3_INVALID_RESPONSE_STATUS for all other non-recoverable response.
1512+
* - Specific error code for recoverable response.
1513+
*/
15071514
static int s_s3_meta_request_error_code_from_response(struct aws_s3_request *request) {
15081515
AWS_PRECONDITION(request);
15091516

@@ -1520,8 +1527,9 @@ static int s_s3_meta_request_error_code_from_response(struct aws_s3_request *req
15201527
struct aws_byte_cursor error_code_string = {0};
15211528
const char *xml_path[] = {"Error", "Code", NULL};
15221529
if (aws_xml_get_body_at_path(request->allocator, xml_doc, xml_path, &error_code_string) == AWS_OP_SUCCESS) {
1523-
/* Found an <Error><Code> string! Map it to CRT error code. */
1524-
error_code_from_xml = aws_s3_crt_error_code_from_server_error_code_string(error_code_string);
1530+
/* Found an <Error><Code> string! Map it to CRT error code if retry-able. */
1531+
error_code_from_xml =
1532+
aws_s3_crt_error_code_from_recoverable_server_error_code_string(error_code_string);
15251533
}
15261534
}
15271535
}

source/s3_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ int aws_s3_calculate_optimal_mpu_part_size_and_num_parts(
702702
return AWS_OP_SUCCESS;
703703
}
704704

705-
int aws_s3_crt_error_code_from_server_error_code_string(struct aws_byte_cursor error_code_string) {
705+
int aws_s3_crt_error_code_from_recoverable_server_error_code_string(struct aws_byte_cursor error_code_string) {
706706
if (aws_byte_cursor_eq_c_str_ignore_case(&error_code_string, "SlowDown")) {
707707
return AWS_ERROR_S3_SLOW_DOWN;
708708
}

0 commit comments

Comments
 (0)