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

Establish `ConnectorError` for errors from SmithyConnector (#744)



* Introduce ClientError to differentiate between different error types coming from HTTP connectors

* Add test

* Fix tests

* Fix the DVR connections

* Fix event-stream client

* clippy cleanups

* Fix poorly named variables in downcast error

* Update docs

* Rename ClientError to ConnectorError

* Fix more incorrectly named errors

* Update rust-runtime/smithy-http/src/result.rs

Co-authored-by: default avatarJohn DiSanti <jdisanti@amazon.com>

* Update changelog

* Update SDK_CHANGELOG.md

Co-authored-by: default avatarJohn DiSanti <jdisanti@amazon.com>
parent 6cc1c514
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -12,12 +12,15 @@ v0.25 (October 7th, 2021)
    to rely on composition instead of inheritance
  - `HttpProtocolTestGenerator` became `ProtocolTestGenerator`
  - `Protocol` moved into `software.amazon.smithy.rust.codegen.smithy.protocols`
- `SmithyConnector` and `DynConnector` now return `ConnectorError` instead of `Box<dyn Error>`. If you have written a custom connector, it will need to be updated to return the new error type. (#744)
- The `DispatchError` variant of `SdkError` now contains `ConnectorError` instead of `Box<dyn Error>` (#744).

**New this week**
- :bug: Fix an issue where `smithy-xml` may have generated invalid XML (smithy-rs#719)
- :bug: Fix error when receiving empty event stream messages (smithy-rs#736)
- :bug: Fix bug in event stream receiver that could cause the last events in the response stream to be lost (smithy-rs#736)

- Add connect & HTTP read timeouts to IMDS, defaulting to 1 second
- IO and timeout errors from Hyper can now be retried (#744)

**Contributors**

+4 −0
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@ vNext (Month Day, Year)

**Breaking changes**
- :warning: MSRV increased from 1.52.1 to 1.53.0 per our 3-behind MSRV policy.
- `SmithyConnector` and `DynConnector` now return `ConnectorError` instead of `Box<dyn Error>`. If you have written a custom connector, it will need to be updated to return the new error type. (#744)
- The `DispatchError` variant of `SdkError` now contains `ConnectorError` instead of `Box<dyn Error>` (#744).

**Tasks to cut release**
- [ ] Bump MSRV on aws-sdk-rust, then delete this line.
@@ -11,6 +13,8 @@ vNext (Month Day, Year)

- :tada: Add presigned request support and examples for S3 GetObject and PutObject (smithy-rs#731, aws-sdk-rust#139)
- :tada: Add presigned request support and example for Polly SynthesizeSpeech (smithy-rs#735, aws-sdk-rust#139)
- Add connect & HTTP read timeouts to IMDS, defaulting to 1 second
- IO and timeout errors from Hyper can now be retried (#744)
- :bug: Fix error when receiving `Cont` event from S3 SelectObjectContent (smithy-rs#736)
- :bug: Fix bug in event stream receiver that could cause the last events in the response stream to be lost when using S3 SelectObjectContent (smithy-rs#736)
- Updated EC2 code examples to include readme; refactored operations from main into separate functions.
+9 −0
Original line number Diff line number Diff line
@@ -61,6 +61,15 @@ where
        let (err, response) = match err {
            Ok(_) => return RetryKind::NotRetryable,
            Err(SdkError::ServiceError { err, raw }) => (err, raw),
            Err(SdkError::DispatchFailure(err)) => {
                return if err.is_timeout() || err.is_io() {
                    RetryKind::Error(ErrorKind::TransientError)
                } else if let Some(ek) = err.is_other() {
                    RetryKind::Error(ek)
                } else {
                    RetryKind::NotRetryable
                }
            }
            Err(_) => return RetryKind::NotRetryable,
        };
        if let Some(retry_after_delay) = response
+3 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
//! [do not need to be repeated]: https://github.com/rust-lang/rust/issues/20671#issuecomment-529752828

use crate::*;
use smithy_http::result::ConnectorError;

/// A service that has parsed a raw Smithy response.
pub type Parsed<S, O, Retry> = smithy_http_tower::parse_response::ParseResponseService<S, O, Retry>;
@@ -38,7 +39,7 @@ pub trait SmithyConnector:
    /// Forwarding type to `<Self as Service>::Error` for bound inference.
    ///
    /// See module-level docs for details.
    type Error: Into<BoxError> + Send + Sync + 'static;
    type Error: Into<ConnectorError> + Send + Sync + 'static;

    /// Forwarding type to `<Self as Service>::Future` for bound inference.
    ///
@@ -53,7 +54,7 @@ where
        + Sync
        + Clone
        + 'static,
    T::Error: Into<BoxError> + Send + Sync + 'static,
    T::Error: Into<ConnectorError> + Send + Sync + 'static,
    T::Future: Send + 'static,
{
    type Error = T::Error;
+3 −2
Original line number Diff line number Diff line
@@ -3,8 +3,9 @@
 * SPDX-License-Identifier: Apache-2.0.
 */

use crate::{bounds, erase, retry, BoxError, Client};
use crate::{bounds, erase, retry, Client};
use smithy_http::body::SdkBody;
use smithy_http::result::ConnectorError;

/// A builder that provides more customization options when constructing a [`Client`].
///
@@ -81,7 +82,7 @@ impl<M, R> Builder<(), M, R> {
    pub fn connector_fn<F, FF>(self, map: F) -> Builder<tower::util::ServiceFn<F>, M, R>
    where
        F: Fn(http::Request<SdkBody>) -> FF + Send,
        FF: std::future::Future<Output = Result<http::Response<SdkBody>, BoxError>>,
        FF: std::future::Future<Output = Result<http::Response<SdkBody>, ConnectorError>>,
        // NOTE: The extra bound here is to help the type checker give better errors earlier.
        tower::util::ServiceFn<F>: bounds::SmithyConnector,
    {
Loading