Skip to content

Commit

Permalink
[s3_meta_request]: Retry on ExpiredToken (#472)
Browse files Browse the repository at this point in the history
Co-authored-by: Dmitriy Musatkin <[email protected]>
Co-authored-by: Waqar Ahmed Khan <[email protected]>
  • Loading branch information
3 people authored Dec 12, 2024
1 parent 58a7adc commit 21a4ab4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/aws/s3/s3.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ enum aws_s3_errors {
AWS_ERROR_S3_RECV_FILE_ALREADY_EXISTS,
AWS_ERROR_S3_RECV_FILE_NOT_FOUND,
AWS_ERROR_S3_REQUEST_TIMEOUT,
AWS_ERROR_S3_TOKEN_EXPIRED,

AWS_ERROR_S3_END_RANGE = AWS_ERROR_ENUM_END_RANGE(AWS_C_S3_PACKAGE_ID)
};
Expand Down
1 change: 1 addition & 0 deletions source/s3.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ static struct aws_error_info s_errors[] = {
AWS_DEFINE_ERROR_INFO_S3(AWS_ERROR_S3_RECV_FILE_ALREADY_EXISTS, "File already exists, cannot create as new."),
AWS_DEFINE_ERROR_INFO_S3(AWS_ERROR_S3_RECV_FILE_NOT_FOUND, "The receive file doesn't exist, cannot create as configuration required."),
AWS_DEFINE_ERROR_INFO_S3(AWS_ERROR_S3_REQUEST_TIMEOUT, "RequestTimeout error received from S3."),
AWS_DEFINE_ERROR_INFO_S3(AWS_ERROR_S3_TOKEN_EXPIRED, "Token expired - needs a refresh."),
};
/* clang-format on */

Expand Down
5 changes: 5 additions & 0 deletions source/s3_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,11 @@ int aws_s3_crt_error_code_from_recoverable_server_error_code_string(struct aws_b
return AWS_ERROR_S3_REQUEST_TIMEOUT;
}

if (aws_byte_cursor_eq_c_str_ignore_case(&error_code_string, "ExpiredToken") ||
aws_byte_cursor_eq_c_str_ignore_case(&error_code_string, "TokenRefreshRequired")) {
return AWS_ERROR_S3_TOKEN_EXPIRED;
}

return AWS_ERROR_UNKNOWN;
}

Expand Down

0 comments on commit 21a4ab4

Please sign in to comment.