smithy icon indicating copy to clipboard operation
smithy copied to clipboard

Specify protocol specific error responses for non-operation errors

Open hlbarber opened this issue 3 years ago • 4 comments

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.

hlbarber avatar Aug 25 '22 17:08 hlbarber

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.

adamthom-amzn avatar Aug 25 '22 20:08 adamthom-amzn

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.

adamthom-amzn avatar Aug 25 '22 20:08 adamthom-amzn

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.

hlbarber avatar Aug 26 '22 17:08 hlbarber

Smithy TypeScript generator has some relevant documented decisions: https://awslabs.github.io/smithy/2.0/ts-ssdk/error-handling.html#synthetic-errors

hlbarber avatar Aug 26 '22 17:08 hlbarber