From 8915cf52c3815e094cd6d30fe6c38963bace3f1e Mon Sep 17 00:00:00 2001 From: John DiSanti Date: Mon, 9 Oct 2023 10:12:32 -0700 Subject: [PATCH] Make `customize()` sync and infallible --- CHANGELOG.next.toml | 6 ++++++ .../rustsdk/CredentialCacheConfigTest.kt | 2 -- .../integration-tests/kms/tests/integration.rs | 4 ---- .../qldbsession/tests/integration.rs | 2 -- .../integration-tests/s3/tests/checksums.rs | 4 ---- .../s3/tests/config-override.rs | 8 -------- .../s3/tests/customizable-operation.rs | 2 -- .../integration-tests/s3/tests/endpoints.rs | 4 ---- .../s3/tests/ignore-invalid-xml-body-root.rs | 2 -- .../integration-tests/s3/tests/interceptors.rs | 4 ---- .../s3/tests/naughty-string-metadata.rs | 2 -- aws/sdk/integration-tests/s3/tests/no_auth.rs | 8 -------- .../s3/tests/normalize-uri-path.rs | 2 -- .../query-strings-are-correctly-encoded.rs | 2 -- .../integration-tests/s3/tests/signing-it.rs | 2 -- .../s3control/tests/signing-it.rs | 2 -- .../codegen/client/smithy/ClientRustModule.kt | 1 - .../generators/client/FluentClientGenerator.kt | 18 ++++-------------- .../MetadataCustomizationTest.kt | 2 -- ...ConfigOverrideRuntimePluginGeneratorTest.kt | 2 -- 20 files changed, 10 insertions(+), 69 deletions(-) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index afe79f7a13..8c370c0ea0 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -291,3 +291,9 @@ message = "`SdkError` is no longer re-exported in generated server crates." references = ["smithy-rs#3038"] meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "server" } author = "jdisanti" + +[[smithy-rs]] +message = "The `customize()` method is now sync and infallible. Remove any `await`s and error handling from it to make things compile again." +references = ["smithy-rs#3039"] +meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "client" } +author = "jdisanti" diff --git a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/CredentialCacheConfigTest.kt b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/CredentialCacheConfigTest.kt index 3685c421af..fe4e9c79d4 100644 --- a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/CredentialCacheConfigTest.kt +++ b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/CredentialCacheConfigTest.kt @@ -156,8 +156,6 @@ internal class CredentialCacheConfigTest { let _ = client .say_hello() .customize() - .await - .unwrap() .config_override(operation_config_override) .send() .await diff --git a/aws/sdk/integration-tests/kms/tests/integration.rs b/aws/sdk/integration-tests/kms/tests/integration.rs index d550337ec5..e02e32ab52 100644 --- a/aws/sdk/integration-tests/kms/tests/integration.rs +++ b/aws/sdk/integration-tests/kms/tests/integration.rs @@ -73,8 +73,6 @@ async fn generate_random() { .generate_random() .number_of_bytes(64) .customize() - .await - .expect("customizable") .mutate_request(|req| { // Remove the invocation ID since the signed request above doesn't have it req.headers_mut().remove("amz-sdk-invocation-id"); @@ -157,8 +155,6 @@ async fn generate_random_keystore_not_found() { .number_of_bytes(64) .custom_key_store_id("does not exist") .customize() - .await - .expect("customizable") .request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1614955644)) .user_agent_for_tests() .send() diff --git a/aws/sdk/integration-tests/qldbsession/tests/integration.rs b/aws/sdk/integration-tests/qldbsession/tests/integration.rs index 3c7a7424fb..18ba8e4999 100644 --- a/aws/sdk/integration-tests/qldbsession/tests/integration.rs +++ b/aws/sdk/integration-tests/qldbsession/tests/integration.rs @@ -45,8 +45,6 @@ async fn signv4_use_correct_service_name() { .unwrap(), ) .customize() - .await - .expect("should be customizable") // Fix the request time and user agent so the headers are stable .request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1614952162)) .user_agent_for_tests() diff --git a/aws/sdk/integration-tests/s3/tests/checksums.rs b/aws/sdk/integration-tests/s3/tests/checksums.rs index e397ec09ae..79b8f92900 100644 --- a/aws/sdk/integration-tests/s3/tests/checksums.rs +++ b/aws/sdk/integration-tests/s3/tests/checksums.rs @@ -74,8 +74,6 @@ async fn test_checksum_on_streaming_response( .key("test.txt") .checksum_mode(aws_sdk_s3::types::ChecksumMode::Enabled) .customize() - .await - .unwrap() .user_agent_for_tests() .send() .await @@ -181,8 +179,6 @@ async fn test_checksum_on_streaming_request<'a>( .body(body) .checksum_algorithm(checksum_algorithm) .customize() - .await - .unwrap() .request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1624036048)) .user_agent_for_tests() .send() diff --git a/aws/sdk/integration-tests/s3/tests/config-override.rs b/aws/sdk/integration-tests/s3/tests/config-override.rs index 44c7006888..76598b764c 100644 --- a/aws/sdk/integration-tests/s3/tests/config-override.rs +++ b/aws/sdk/integration-tests/s3/tests/config-override.rs @@ -27,8 +27,6 @@ async fn operation_overrides_force_path_style() { .list_objects_v2() .bucket("test-bucket") .customize() - .await - .unwrap() .config_override(aws_sdk_s3::config::Config::builder().force_path_style(true)) .send() .await; @@ -45,8 +43,6 @@ async fn operation_overrides_fips() { .list_objects_v2() .bucket("test-bucket") .customize() - .await - .unwrap() .config_override(aws_sdk_s3::config::Config::builder().use_fips(true)) .send() .await; @@ -63,8 +59,6 @@ async fn operation_overrides_dual_stack() { .list_objects_v2() .bucket("test-bucket") .customize() - .await - .unwrap() .config_override(aws_sdk_s3::config::Config::builder().use_dual_stack(true)) .send() .await; @@ -85,8 +79,6 @@ async fn operation_overrides_credentials_provider() { .list_objects_v2() .bucket("test-bucket") .customize() - .await - .unwrap() .config_override(aws_sdk_s3::config::Config::builder().credentials_provider(Credentials::new( "test", "test", diff --git a/aws/sdk/integration-tests/s3/tests/customizable-operation.rs b/aws/sdk/integration-tests/s3/tests/customizable-operation.rs index 6bd55816c0..b7c7dfbf55 100644 --- a/aws/sdk/integration-tests/s3/tests/customizable-operation.rs +++ b/aws/sdk/integration-tests/s3/tests/customizable-operation.rs @@ -26,8 +26,6 @@ async fn test_s3_ops_are_customizable() { let op = client .list_buckets() .customize() - .await - .expect("list_buckets is customizable") .request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1624036048)) .user_agent_for_tests(); diff --git a/aws/sdk/integration-tests/s3/tests/endpoints.rs b/aws/sdk/integration-tests/s3/tests/endpoints.rs index 5ac1ac7ad8..2c31986007 100644 --- a/aws/sdk/integration-tests/s3/tests/endpoints.rs +++ b/aws/sdk/integration-tests/s3/tests/endpoints.rs @@ -70,8 +70,6 @@ async fn multi_region_access_points() { .bucket("arn:aws:s3::123456789012:accesspoint/mfzwi23gnjvgw.mrap") .key("blah") .customize() - .await - .unwrap() .request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1624036048)) .user_agent_for_tests() .send() @@ -103,8 +101,6 @@ async fn s3_object_lambda() { .bucket("arn:aws:s3-object-lambda:us-east-100:123412341234:accesspoint/myolap") .key("s3.txt") .customize() - .await - .unwrap() .request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1234567890)) .send() .await diff --git a/aws/sdk/integration-tests/s3/tests/ignore-invalid-xml-body-root.rs b/aws/sdk/integration-tests/s3/tests/ignore-invalid-xml-body-root.rs index b120a34188..25a7a34e0b 100644 --- a/aws/sdk/integration-tests/s3/tests/ignore-invalid-xml-body-root.rs +++ b/aws/sdk/integration-tests/s3/tests/ignore-invalid-xml-body-root.rs @@ -56,8 +56,6 @@ async fn ignore_invalid_xml_body_root() { .key("test.txt") .object_attributes(ObjectAttributes::Checksum) .customize() - .await - .unwrap() .request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1624036048)) .user_agent_for_tests() .send() diff --git a/aws/sdk/integration-tests/s3/tests/interceptors.rs b/aws/sdk/integration-tests/s3/tests/interceptors.rs index 62bc29b039..7263b6d200 100644 --- a/aws/sdk/integration-tests/s3/tests/interceptors.rs +++ b/aws/sdk/integration-tests/s3/tests/interceptors.rs @@ -74,8 +74,6 @@ async fn interceptor_priority() { .bucket("test-bucket") .prefix("prefix~") .customize() - .await - .unwrap() .interceptor(TestInterceptor("value2")) .send() .await @@ -103,8 +101,6 @@ async fn set_test_user_agent_through_request_mutation() { .bucket("test-bucket") .prefix("prefix~") .customize() - .await - .unwrap() .mutate_request(|request| { let headers = request.headers_mut(); headers.insert(USER_AGENT, HeaderValue::try_from("test").unwrap()); diff --git a/aws/sdk/integration-tests/s3/tests/naughty-string-metadata.rs b/aws/sdk/integration-tests/s3/tests/naughty-string-metadata.rs index 209fd6bcde..422d64c899 100644 --- a/aws/sdk/integration-tests/s3/tests/naughty-string-metadata.rs +++ b/aws/sdk/integration-tests/s3/tests/naughty-string-metadata.rs @@ -79,8 +79,6 @@ async fn test_s3_signer_with_naughty_string_metadata() { let _ = builder .customize() - .await - .unwrap() .request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1624036048)) .user_agent_for_tests() .send() diff --git a/aws/sdk/integration-tests/s3/tests/no_auth.rs b/aws/sdk/integration-tests/s3/tests/no_auth.rs index 670d85268c..f7e8f477ea 100644 --- a/aws/sdk/integration-tests/s3/tests/no_auth.rs +++ b/aws/sdk/integration-tests/s3/tests/no_auth.rs @@ -25,8 +25,6 @@ async fn list_objects() { .bucket("gdc-organoid-pancreatic-phs001611-2-open") .max_keys(3) .customize() - .await - .unwrap() .remove_invocation_id_for_tests() .user_agent_for_tests() .send() @@ -58,8 +56,6 @@ async fn list_objects_v2() { .bucket("gdc-organoid-pancreatic-phs001611-2-open") .max_keys(3) .customize() - .await - .unwrap() .remove_invocation_id_for_tests() .user_agent_for_tests() .send() @@ -90,8 +86,6 @@ async fn head_object() { .bucket("gdc-organoid-pancreatic-phs001611-2-open") .key("0431cddc-a418-4a79-a34d-6c041394e8e4/a6ddcc84-8e4d-4c68-885c-2d51168eec97.FPKM-UQ.txt.gz") .customize() - .await - .unwrap() .remove_invocation_id_for_tests() .user_agent_for_tests() .send() @@ -122,8 +116,6 @@ async fn get_object() { .bucket("gdc-organoid-pancreatic-phs001611-2-open") .key("0431cddc-a418-4a79-a34d-6c041394e8e4/a6ddcc84-8e4d-4c68-885c-2d51168eec97.FPKM-UQ.txt.gz") .customize() - .await - .unwrap() .remove_invocation_id_for_tests() .user_agent_for_tests() .send() diff --git a/aws/sdk/integration-tests/s3/tests/normalize-uri-path.rs b/aws/sdk/integration-tests/s3/tests/normalize-uri-path.rs index e91af82846..ae8426d16c 100644 --- a/aws/sdk/integration-tests/s3/tests/normalize-uri-path.rs +++ b/aws/sdk/integration-tests/s3/tests/normalize-uri-path.rs @@ -31,8 +31,6 @@ async fn test_operation_should_not_normalize_uri_path() { .key("a/.././b.txt") // object key with dot segments .body(ByteStream::from_static("Hello, world".as_bytes())) .customize() - .await - .unwrap() .request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1669257290)) .user_agent_for_tests() .send() diff --git a/aws/sdk/integration-tests/s3/tests/query-strings-are-correctly-encoded.rs b/aws/sdk/integration-tests/s3/tests/query-strings-are-correctly-encoded.rs index 67557f6e05..9f688fe69b 100644 --- a/aws/sdk/integration-tests/s3/tests/query-strings-are-correctly-encoded.rs +++ b/aws/sdk/integration-tests/s3/tests/query-strings-are-correctly-encoded.rs @@ -33,8 +33,6 @@ async fn test_s3_signer_query_string_with_all_valid_chars() { .bucket("test-bucket") .prefix(&prefix) .customize() - .await - .unwrap() .request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1624036048)) .user_agent_for_tests() .send() diff --git a/aws/sdk/integration-tests/s3/tests/signing-it.rs b/aws/sdk/integration-tests/s3/tests/signing-it.rs index d739bec6c1..1b3e59e373 100644 --- a/aws/sdk/integration-tests/s3/tests/signing-it.rs +++ b/aws/sdk/integration-tests/s3/tests/signing-it.rs @@ -34,8 +34,6 @@ async fn test_signer() { .bucket("test-bucket") .prefix("prefix~") .customize() - .await - .unwrap() .request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1624036048)) .user_agent_for_tests() .send() diff --git a/aws/sdk/integration-tests/s3control/tests/signing-it.rs b/aws/sdk/integration-tests/s3control/tests/signing-it.rs index 7a1a585d1c..b94e397170 100644 --- a/aws/sdk/integration-tests/s3control/tests/signing-it.rs +++ b/aws/sdk/integration-tests/s3control/tests/signing-it.rs @@ -37,8 +37,6 @@ async fn test_signer() { .list_access_points() .account_id("test-bucket") .customize() - .await - .unwrap() .request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1636751225)) .user_agent_for_tests() .remove_invocation_id_for_tests() diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustModule.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustModule.kt index 284ed53563..7c882a3f4b 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustModule.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustModule.kt @@ -149,7 +149,6 @@ class ClientModuleDocProvider( let result = client.$opFnName() .customize() - .await? .mutate_request(|req| { // Add `x-example-header` with value req.headers_mut() diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt index 4a9c162696..c1d9dbae02 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt @@ -371,21 +371,11 @@ class FluentClientGenerator( #{Operation}::orchestrate(&runtime_plugins, input).await } - /// Consumes this builder, creating a customizable operation that can be modified before being - /// sent. - // TODO(enableNewSmithyRuntimeCleanup): Remove `async` and `Result` once we switch to orchestrator - pub async fn customize( + /// Consumes this builder, creating a customizable operation that can be modified before being sent. + pub fn customize( self, - ) -> #{Result}< - #{CustomizableOperation}< - #{OperationOutput}, - #{OperationError}, - Self, - >, - #{SdkError}<#{OperationError}>, - > - { - #{Ok}(#{CustomizableOperation}::new(self)) + ) -> #{CustomizableOperation}<#{OperationOutput}, #{OperationError}, Self> { + #{CustomizableOperation}::new(self) } """, *orchestratorScope, diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/MetadataCustomizationTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/MetadataCustomizationTest.kt index 9010b94659..e959dd333a 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/MetadataCustomizationTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/MetadataCustomizationTest.kt @@ -90,8 +90,6 @@ class MetadataCustomizationTest { let _ = client .say_hello() .customize() - .await - .expect("operation should be customizable") .interceptor(ExtractMetadataInterceptor(::std::sync::Mutex::new(#{Some}(tx)))) .send() .await; diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ConfigOverrideRuntimePluginGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ConfigOverrideRuntimePluginGeneratorTest.kt index e7a4ed760f..6772f463af 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ConfigOverrideRuntimePluginGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ConfigOverrideRuntimePluginGeneratorTest.kt @@ -118,8 +118,6 @@ internal class ConfigOverrideRuntimePluginGeneratorTest { let customizable_send = client .say_hello() .customize() - .await - .unwrap() .config_override(crate::config::Config::builder().http_client(http_client)) .send();