Skip to content

Commit 6b96c1d

Browse files
authored
Make customize() sync and infallible (#3039)
This PR addresses a TODO comment to make `customize()` sync and fallible. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
1 parent 08196ec commit 6b96c1d

File tree

20 files changed

+10
-69
lines changed

20 files changed

+10
-69
lines changed

CHANGELOG.next.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,3 +291,9 @@ message = "`SdkError` is no longer re-exported in generated server crates."
291291
references = ["smithy-rs#3038"]
292292
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "server" }
293293
author = "jdisanti"
294+
295+
[[smithy-rs]]
296+
message = "The `customize()` method is now sync and infallible. Remove any `await`s and error handling from it to make things compile again."
297+
references = ["smithy-rs#3039"]
298+
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "client" }
299+
author = "jdisanti"

aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/CredentialCacheConfigTest.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,6 @@ internal class CredentialCacheConfigTest {
156156
let _ = client
157157
.say_hello()
158158
.customize()
159-
.await
160-
.unwrap()
161159
.config_override(operation_config_override)
162160
.send()
163161
.await

aws/sdk/integration-tests/kms/tests/integration.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ async fn generate_random() {
7373
.generate_random()
7474
.number_of_bytes(64)
7575
.customize()
76-
.await
77-
.expect("customizable")
7876
.mutate_request(|req| {
7977
// Remove the invocation ID since the signed request above doesn't have it
8078
req.headers_mut().remove("amz-sdk-invocation-id");
@@ -157,8 +155,6 @@ async fn generate_random_keystore_not_found() {
157155
.number_of_bytes(64)
158156
.custom_key_store_id("does not exist")
159157
.customize()
160-
.await
161-
.expect("customizable")
162158
.request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1614955644))
163159
.user_agent_for_tests()
164160
.send()

aws/sdk/integration-tests/qldbsession/tests/integration.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ async fn signv4_use_correct_service_name() {
4545
.unwrap(),
4646
)
4747
.customize()
48-
.await
49-
.expect("should be customizable")
5048
// Fix the request time and user agent so the headers are stable
5149
.request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1614952162))
5250
.user_agent_for_tests()

aws/sdk/integration-tests/s3/tests/checksums.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ async fn test_checksum_on_streaming_response(
7474
.key("test.txt")
7575
.checksum_mode(aws_sdk_s3::types::ChecksumMode::Enabled)
7676
.customize()
77-
.await
78-
.unwrap()
7977
.user_agent_for_tests()
8078
.send()
8179
.await
@@ -181,8 +179,6 @@ async fn test_checksum_on_streaming_request<'a>(
181179
.body(body)
182180
.checksum_algorithm(checksum_algorithm)
183181
.customize()
184-
.await
185-
.unwrap()
186182
.request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1624036048))
187183
.user_agent_for_tests()
188184
.send()

aws/sdk/integration-tests/s3/tests/config-override.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ async fn operation_overrides_force_path_style() {
2727
.list_objects_v2()
2828
.bucket("test-bucket")
2929
.customize()
30-
.await
31-
.unwrap()
3230
.config_override(aws_sdk_s3::config::Config::builder().force_path_style(true))
3331
.send()
3432
.await;
@@ -45,8 +43,6 @@ async fn operation_overrides_fips() {
4543
.list_objects_v2()
4644
.bucket("test-bucket")
4745
.customize()
48-
.await
49-
.unwrap()
5046
.config_override(aws_sdk_s3::config::Config::builder().use_fips(true))
5147
.send()
5248
.await;
@@ -63,8 +59,6 @@ async fn operation_overrides_dual_stack() {
6359
.list_objects_v2()
6460
.bucket("test-bucket")
6561
.customize()
66-
.await
67-
.unwrap()
6862
.config_override(aws_sdk_s3::config::Config::builder().use_dual_stack(true))
6963
.send()
7064
.await;
@@ -85,8 +79,6 @@ async fn operation_overrides_credentials_provider() {
8579
.list_objects_v2()
8680
.bucket("test-bucket")
8781
.customize()
88-
.await
89-
.unwrap()
9082
.config_override(aws_sdk_s3::config::Config::builder().credentials_provider(Credentials::new(
9183
"test",
9284
"test",

aws/sdk/integration-tests/s3/tests/customizable-operation.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ async fn test_s3_ops_are_customizable() {
2626
let op = client
2727
.list_buckets()
2828
.customize()
29-
.await
30-
.expect("list_buckets is customizable")
3129
.request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1624036048))
3230
.user_agent_for_tests();
3331

aws/sdk/integration-tests/s3/tests/endpoints.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ async fn multi_region_access_points() {
7070
.bucket("arn:aws:s3::123456789012:accesspoint/mfzwi23gnjvgw.mrap")
7171
.key("blah")
7272
.customize()
73-
.await
74-
.unwrap()
7573
.request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1624036048))
7674
.user_agent_for_tests()
7775
.send()
@@ -103,8 +101,6 @@ async fn s3_object_lambda() {
103101
.bucket("arn:aws:s3-object-lambda:us-east-100:123412341234:accesspoint/myolap")
104102
.key("s3.txt")
105103
.customize()
106-
.await
107-
.unwrap()
108104
.request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1234567890))
109105
.send()
110106
.await

aws/sdk/integration-tests/s3/tests/ignore-invalid-xml-body-root.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ async fn ignore_invalid_xml_body_root() {
5656
.key("test.txt")
5757
.object_attributes(ObjectAttributes::Checksum)
5858
.customize()
59-
.await
60-
.unwrap()
6159
.request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1624036048))
6260
.user_agent_for_tests()
6361
.send()

aws/sdk/integration-tests/s3/tests/interceptors.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ async fn interceptor_priority() {
7474
.bucket("test-bucket")
7575
.prefix("prefix~")
7676
.customize()
77-
.await
78-
.unwrap()
7977
.interceptor(TestInterceptor("value2"))
8078
.send()
8179
.await
@@ -103,8 +101,6 @@ async fn set_test_user_agent_through_request_mutation() {
103101
.bucket("test-bucket")
104102
.prefix("prefix~")
105103
.customize()
106-
.await
107-
.unwrap()
108104
.mutate_request(|request| {
109105
let headers = request.headers_mut();
110106
headers.insert(USER_AGENT, HeaderValue::try_from("test").unwrap());

aws/sdk/integration-tests/s3/tests/naughty-string-metadata.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ async fn test_s3_signer_with_naughty_string_metadata() {
7979

8080
let _ = builder
8181
.customize()
82-
.await
83-
.unwrap()
8482
.request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1624036048))
8583
.user_agent_for_tests()
8684
.send()

aws/sdk/integration-tests/s3/tests/no_auth.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ async fn list_objects() {
2525
.bucket("gdc-organoid-pancreatic-phs001611-2-open")
2626
.max_keys(3)
2727
.customize()
28-
.await
29-
.unwrap()
3028
.remove_invocation_id_for_tests()
3129
.user_agent_for_tests()
3230
.send()
@@ -58,8 +56,6 @@ async fn list_objects_v2() {
5856
.bucket("gdc-organoid-pancreatic-phs001611-2-open")
5957
.max_keys(3)
6058
.customize()
61-
.await
62-
.unwrap()
6359
.remove_invocation_id_for_tests()
6460
.user_agent_for_tests()
6561
.send()
@@ -90,8 +86,6 @@ async fn head_object() {
9086
.bucket("gdc-organoid-pancreatic-phs001611-2-open")
9187
.key("0431cddc-a418-4a79-a34d-6c041394e8e4/a6ddcc84-8e4d-4c68-885c-2d51168eec97.FPKM-UQ.txt.gz")
9288
.customize()
93-
.await
94-
.unwrap()
9589
.remove_invocation_id_for_tests()
9690
.user_agent_for_tests()
9791
.send()
@@ -122,8 +116,6 @@ async fn get_object() {
122116
.bucket("gdc-organoid-pancreatic-phs001611-2-open")
123117
.key("0431cddc-a418-4a79-a34d-6c041394e8e4/a6ddcc84-8e4d-4c68-885c-2d51168eec97.FPKM-UQ.txt.gz")
124118
.customize()
125-
.await
126-
.unwrap()
127119
.remove_invocation_id_for_tests()
128120
.user_agent_for_tests()
129121
.send()

aws/sdk/integration-tests/s3/tests/normalize-uri-path.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ async fn test_operation_should_not_normalize_uri_path() {
3131
.key("a/.././b.txt") // object key with dot segments
3232
.body(ByteStream::from_static("Hello, world".as_bytes()))
3333
.customize()
34-
.await
35-
.unwrap()
3634
.request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1669257290))
3735
.user_agent_for_tests()
3836
.send()

aws/sdk/integration-tests/s3/tests/query-strings-are-correctly-encoded.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ async fn test_s3_signer_query_string_with_all_valid_chars() {
3333
.bucket("test-bucket")
3434
.prefix(&prefix)
3535
.customize()
36-
.await
37-
.unwrap()
3836
.request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1624036048))
3937
.user_agent_for_tests()
4038
.send()

aws/sdk/integration-tests/s3/tests/signing-it.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ async fn test_signer() {
3434
.bucket("test-bucket")
3535
.prefix("prefix~")
3636
.customize()
37-
.await
38-
.unwrap()
3937
.request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1624036048))
4038
.user_agent_for_tests()
4139
.send()

aws/sdk/integration-tests/s3control/tests/signing-it.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ async fn test_signer() {
3737
.list_access_points()
3838
.account_id("test-bucket")
3939
.customize()
40-
.await
41-
.unwrap()
4240
.request_time_for_tests(UNIX_EPOCH + Duration::from_secs(1636751225))
4341
.user_agent_for_tests()
4442
.remove_invocation_id_for_tests()

codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustModule.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ class ClientModuleDocProvider(
149149
150150
let result = client.$opFnName()
151151
.customize()
152-
.await?
153152
.mutate_request(|req| {
154153
// Add `x-example-header` with value
155154
req.headers_mut()

codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -371,21 +371,11 @@ class FluentClientGenerator(
371371
#{Operation}::orchestrate(&runtime_plugins, input).await
372372
}
373373
374-
/// Consumes this builder, creating a customizable operation that can be modified before being
375-
/// sent.
376-
// TODO(enableNewSmithyRuntimeCleanup): Remove `async` and `Result` once we switch to orchestrator
377-
pub async fn customize(
374+
/// Consumes this builder, creating a customizable operation that can be modified before being sent.
375+
pub fn customize(
378376
self,
379-
) -> #{Result}<
380-
#{CustomizableOperation}<
381-
#{OperationOutput},
382-
#{OperationError},
383-
Self,
384-
>,
385-
#{SdkError}<#{OperationError}>,
386-
>
387-
{
388-
#{Ok}(#{CustomizableOperation}::new(self))
377+
) -> #{CustomizableOperation}<#{OperationOutput}, #{OperationError}, Self> {
378+
#{CustomizableOperation}::new(self)
389379
}
390380
""",
391381
*orchestratorScope,

codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/MetadataCustomizationTest.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ class MetadataCustomizationTest {
9090
let _ = client
9191
.say_hello()
9292
.customize()
93-
.await
94-
.expect("operation should be customizable")
9593
.interceptor(ExtractMetadataInterceptor(::std::sync::Mutex::new(#{Some}(tx))))
9694
.send()
9795
.await;

codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ConfigOverrideRuntimePluginGeneratorTest.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ internal class ConfigOverrideRuntimePluginGeneratorTest {
118118
let customizable_send = client
119119
.say_hello()
120120
.customize()
121-
.await
122-
.unwrap()
123121
.config_override(crate::config::Config::builder().http_client(http_client))
124122
.send();
125123

0 commit comments

Comments
 (0)