Unverified Commit 89d984df authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

Fix Retryability of Unmodeled Errors (#277)

A bug was introduced which caused unmodeled response codes to be lost during error handling. This caused the unmodeled errors to always be marked as "unretryable" because their code wasn't exposed to the retry policy. This diff adds a fix and integration test for this behavior.
parent c049a37f
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -41,3 +41,22 @@ fn errors_are_retryable() {
    let retry_kind = parts.retry_policy.classify(err.as_ref());
    assert_eq!(retry_kind, RetryKind::Error(ErrorKind::ThrottlingError));
}

#[test]
fn unmodeled_errors_are_retryable() {
    let conf = kms::Config::builder().build();
    let (_, parts) = CreateAlias::builder().build(&conf).expect("valid request").into_request_response();
    let http_response = http::Response::builder()
        .status(400)
        .body(r#"{ "code": "ThrottlingException" }"#)
        .unwrap();
    let err = parts
        .response_handler
        .parse_response(&http_response)
        .map_err(|e| SdkError::ServiceError {
            err: e,
            raw: http_response.map(ResponseBody::from_static),
        });
    let retry_kind = parts.retry_policy.classify(err.as_ref());
    assert_eq!(retry_kind, RetryKind::Error(ErrorKind::ThrottlingError));
}
+1 −1
Original line number Diff line number Diff line
@@ -303,6 +303,6 @@ class BasicAwsJsonGenerator(
                write("Err(e) => #T::unhandled(e)", errorSymbol)
            }
        }
        write("_ => #T::unhandled(generic)", errorSymbol)
        write("_ => #T::generic(generic)", errorSymbol)
    }
}