Unverified Commit 30a801a8 authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Fix subtle break of endpoint prefixes due to semver (#3318)

When we released smithy-rs release-2023-12-08, we introduced a silent
failure for endpoint prefixes, and not in the newly released version,
but in the previous releases. There is a subtle issue with semver that
causes this. This PR addresses the endpoint prefix part of this problem.
Other PRs will fix other parts that are broken by this semver issue.

The issue is that unstable (0.x) runtime crates are declaring types that
get placed into the `ConfigBag`, and these types are referenced in the
`ConfigBag` across crate boundaries. This by itself isn't a problem, but
because our stable 1.x crates depend on the unstable crates, it becomes
a problem. By releasing 1.1.0 that depends on 0.61, consumers of 1.x
pull in both 0.60 and 0.61. The generated code pulls in 0.60, and the
1.1.x crates pull in 0.61. This is fine since two semver-incompatible
crate versions can be in the dependency closure. Thus, the generated
code which is using 0.60 is placing a 0.60 type in the `ConfigBag`, and
the runtime crates that pull the type out of the `ConfigBag` are
expecting a 0.61 version of it. This leads to the type not existing upon
lookup, which then causes the silent break.

This PR fixes this by moving the `EndpointPrefix` type and its
associated methods into `aws-smithy-runtime-api`, a stable crate. The
`aws-smithy-http` unstable crate is updated to point to the new stable
version so that a patch release of that crate will solve the issue for
old versions going forward as well.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
parent e3f0de42
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -11,6 +11,18 @@
# meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client | server | all"}
# author = "rcoh"

[[aws-sdk-rust]]
message = "`EndpointPrefix` and `apply_endpoint` moved from aws-smithy-http to aws-smithy-runtime-api so that is in a stable (1.x) crate. A deprecated type alias was left in place with a note showing the new location."
references = ["smithy-rs#3318"]
meta = { "breaking" = false, "tada" = false, "bug" = false }
author = "jdisanti"

[[smithy-rs]]
message = "`EndpointPrefix` and `apply_endpoint` moved from aws-smithy-http to aws-smithy-runtime-api so that is in a stable (1.x) crate. A deprecated type alias was left in place with a note showing the new location."
references = ["smithy-rs#3318"]
meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client"}
author = "jdisanti"

[[smithy-rs]]
message = "The `Metadata` storable was moved from aws_smithy_http into aws_smithy_runtime_api. A deprecated type alias was left in place with a note showing where the new location is."
references = ["smithy-rs#3325"]
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@
use crate::http_credential_provider::HttpCredentialProvider;
use crate::provider_config::ProviderConfig;
use aws_credential_types::provider::{self, error::CredentialsError, future, ProvideCredentials};
use aws_smithy_http::endpoint::apply_endpoint;
use aws_smithy_runtime::client::endpoint::apply_endpoint;
use aws_smithy_runtime_api::client::dns::{ResolveDns, ResolveDnsError, SharedDnsResolver};
use aws_smithy_runtime_api::client::http::HttpConnectorSettings;
use aws_smithy_runtime_api::shared::IntoShared;
+3 −1
Original line number Diff line number Diff line
@@ -15,7 +15,9 @@ use http::HeaderValue;

/// Interceptor that adds an Accept header to API Gateway requests.
#[derive(Debug, Default)]
pub(crate) struct AcceptHeaderInterceptor;
pub(crate) struct AcceptHeaderInterceptor {
    _priv: (),
}

impl Intercept for AcceptHeaderInterceptor {
    fn name(&self) -> &'static str {
+3 −3
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ class EndpointTraitBindings(
    private val endpointTrait: EndpointTrait,
) {
    private val inputShape = operationShape.inputShape(model)
    private val endpointPrefix = RuntimeType.smithyHttp(runtimeConfig).resolve("endpoint::EndpointPrefix")
    private val endpointPrefix = RuntimeType.smithyRuntimeApiClient(runtimeConfig).resolve("client::endpoint::EndpointPrefix")

    /**
     * Render the `EndpointPrefix` struct. [input] refers to the symbol referring to the input of this operation.
@@ -82,8 +82,8 @@ class EndpointTraitBindings(
                            rustTemplate(
                                contents,
                                "InvalidEndpointError" to
                                    RuntimeType.smithyHttp(runtimeConfig)
                                        .resolve("endpoint::error::InvalidEndpointError"),
                                    RuntimeType.smithyRuntimeApiClient(runtimeConfig)
                                        .resolve("client::endpoint::error::InvalidEndpointError"),
                            )
                        }
                        "${label.content} = $field"
+4 −3
Original line number Diff line number Diff line
@@ -72,8 +72,9 @@ internal class EndpointTraitBindingsTest {
            )
            implBlock(symbolProvider.toSymbol(model.lookup("test#GetStatusInput"))) {
                rustBlockTemplate(
                    "fn endpoint_prefix(&self) -> std::result::Result<#{endpoint}::EndpointPrefix, #{endpoint}::error::InvalidEndpointError>",
                    "endpoint" to RuntimeType.smithyHttp(TestRuntimeConfig).resolve("endpoint"),
                    "fn endpoint_prefix(&self) -> std::result::Result<#{EndpointPrefix}, #{InvalidEndpointError}>",
                    "EndpointPrefix" to RuntimeType.smithyRuntimeApiClient(TestRuntimeConfig).resolve("client::endpoint::EndpointPrefix"),
                    "InvalidEndpointError" to RuntimeType.smithyRuntimeApiClient(TestRuntimeConfig).resolve("client::endpoint::error::InvalidEndpointError"),
                ) {
                    endpointBindingGenerator.render(this, "self")
                }
@@ -162,8 +163,8 @@ internal class EndpointTraitBindingsTest {
                    """
                    async fn test_endpoint_prefix() {
                        use #{capture_request};
                        use aws_smithy_http::endpoint::EndpointPrefix;
                        use aws_smithy_runtime_api::box_error::BoxError;
                        use aws_smithy_runtime_api::client::endpoint::EndpointPrefix;
                        use aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
                        use aws_smithy_types::body::SdkBody;
                        use aws_smithy_types::config_bag::ConfigBag;
Loading