Closed ysaito1001 closed 1 month ago
A new generated diff is ready to view.
A new doc preview is ready to view.
A new generated diff is ready to view.
A new doc preview is ready to view.
A new generated diff is ready to view.
A new doc preview is ready to view.
Motivation and Context
If a client SDK is generated from a service model that has the
awsQueryCompatible
trait, the SDK now sendsx-amzn-query-mode
in the request header for the service.Description
The change in the PR itself is pretty simple, as said in the title. It's more important to understand why we are making these changes. The rest of the description will focus on the reason driving this change.
The
awsQueryCompatible
trait, added by a service, is specifically for deserializing errors. It allows for deserializing errors in a backward compatible manner when the service migrates away from the AWS Query protocol.With the awsQueryError trait, the AWS Query supports customizing error codes that is not supported in any other AWS protocol, e.g.
In short, the
awsQueryCompatible
trait makes it possible to continue using the custom error codes even when the service drops support for the AWS Query protocol and switches to other protocols such asawsJson1_0
andrpcv2Cbor
(see example snippet in the Smithy documentation)The changes in this PR would be unnecessary if a service had originally supported only
@awsQuery
and had atomically updated its Smithy model to replace@awsQuery
with@awsQueryCompatible
and@awsJson1_0
in lockstep. However, that's not always the case in practice.Consider a service whose Smithy model supports two protocols:
@awsQuery
and@awsJson1_0
. While the Rust SDK maintains an ordered map of protocols to determine which one to use, it’s possible for two groups of client SDKs to be generated over time, depending on which protocol was added first to the service:awsQuery
protocol (this group can interpret custom error codes sent in responses from the service)awsJson1_0
protocol (this group does not interpret custom error codes)Now, imagine if the service updated its Smithy model to remove
@awsQuery
and add@awsQueryCompatible
(likely it would add theawsQueryError
trait to an error structure somewhere as well). The supported protocols would then be@awsJson1_0
and@awsQueryCompatible
. Group 1 remains unaffected, as they can continue deserializing responses with custom error codes. However, group 2 would now be broken, as they would begin receiving custom error codes in responses due to theawsQueryCompatible
trait.To prevent the issue for group 2 above, the
x-amzn-query-mode
header in this PR informs the service that it should only send back custom error codes if the client SDK is built with theawsQueryCompatible
trait. With this update, client SDKs built only with theawsJson1_0
will remain unaffected, as they do not send thex-amzn-query-mode
header to the service and, therefore, will not receive custom error codes in response.Testing
x-amzn-query-mode
headerx-amzn-query-mode
as a required header to a protocol test for theawsQueryCompatible
Checklist
.changelog
directory, specifying "aws-sdk-rust" in theapplies_to
key.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.