mirror of https://github.com/smithy-lang/smithy-rs
4b66264db1
## Motivation and Context
If a client SDK is generated from a service model that has the
[`awsQueryCompatible`](https://smithy.io/2.0/aws/protocols/aws-query-protocol.html#aws-protocols-awsquerycompatible-trait)
trait, the SDK now sends `x-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](https://smithy.io/2.0/aws/protocols/aws-query-protocol.html#aws-protocols-awsqueryerror-trait),
the AWS Query supports customizing error codes that is not supported in
any other AWS protocol, e.g.
```
@awsQueryError(
code: "AWS.SimpleQueueService.NonExistentQueue",
httpResponseCode: 400
)
@error("client")
structure QueueDoesNotExistException {
message: String
}
```
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 as `awsJson1_0`
and `rpcv2Cbor` (see [example
snippet](https://smithy.io/2.0/aws/protocols/aws-query-protocol.html#aws-protocols-awsquerycompatible-trait)
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](
|
||
---|---|---|
.. | ||
aws-json-query-compat.smithy | ||
constraints.smithy | ||
ebs.json | ||
misc.smithy | ||
naming-obstacle-course-casing.smithy | ||
naming-obstacle-course-ops.smithy | ||
naming-obstacle-course-structs.smithy | ||
pokemon-awsjson.smithy | ||
pokemon-common.smithy | ||
pokemon.smithy | ||
rest-json-extras.smithy | ||
rpcv2Cbor-extras.smithy | ||
simple.smithy | ||
unique-items.smithy |