smithy
smithy copied to clipboard
Specify protocol specific error responses for non-operation errors
At the time of writing, as far as I can tell, the AWS protocols specify how operation errors are serialized but does not specify how errors outside of that should be responded to.
For example, AWS restJson1 defines a set of Protocol Behaviours, one of which is
Every request for the awsJson1_0 protocol MUST be sent to the root URL (/) using the HTTP "POST" method.
but does not specify the response when a request is received which fails this criteria.
The existing service framework supports multiple protocols out of the box, and protocol handlers will refuse to claim a job that they don't think they can service. So in this case, the AWS/JSON 1.0 handler would not claim the job; if no handlers claimed the job, the default behavior would be an UnknownOperationException 404.
This sort of ambiguity is why future protocols are designed with specific protocol declaration headers instead of being bound by a set of matching criteria.
Returning UnknownOperationException + 404 on routing failure sounds reasonable. Should this be something that is covered by Smithy documentation/protocol tests? I'm hesitant to commit to behavior on the smithy-rs side before deliberation and a conclusion is made.
Smithy TypeScript generator has some relevant documented decisions: https://awslabs.github.io/smithy/2.0/ts-ssdk/error-handling.html#synthetic-errors