Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflicts between Smithy semantics and HTTP specification #1244

Closed
hlbarber opened this issue May 31, 2022 · 1 comment · Fixed by #1254
Closed

Conflicts between Smithy semantics and HTTP specification #1244

hlbarber opened this issue May 31, 2022 · 1 comment · Fixed by #1254

Comments

@hlbarber
Copy link
Contributor

hlbarber commented May 31, 2022

What should happen in situations where the semantics of Smithy conflict with the HTTP spec?

Consider the following example:

@http(method: "PUT", uri: "/", code: 204)
operation Put {
    output: Output
}

@output
structure Output {
    someValue: String
}

The HTTP spec forbids a 204 response to have a message-body. https://httpwg.org/specs/rfc7231.html#status.204

A 204 response is terminated by the first empty line after the header fields because it cannot contain a message body.

Should the semantics of this operation yield to the HTTP spec? i.e. should the payload get removed to be in compliance?

In the case of smithy-rs we are backed by hyper.

It will not provide Content-Length headers in accordance with https://httpwg.org/specs/rfc7230.html#header.content-length

A server MUST NOT send a Content-Length header field in any response with a status code of 1xx (Informational) or 204 (No Content). A server MUST NOT send a Content-Length header field in any 2xx (Successful) response to a CONNECT request.

See hyperium/hyper#2216.

It will also do a variety of checks in relation to the spec.

A further example of such a collision is with https://awslabs.github.io/smithy/1.0/spec/core/http-traits.html#httpheader-trait, although @httpHeader("Content-Length") is marked as "highly discouraged", hyper would also cause problems honoring this for 1xx, 204, and 304 responses.

Some clarification on these issues would be appreciated.

@mtdowling
Copy link
Member

We could add a note in the spec that says to be aware of HTTP limitations, call out specifically 204 as an example, and call out that violating the HTTP spec in a Smithy model is undefined behavior with no expectation of working across languages or implementations. I think that's a better approach than trying to cover every edge case of HTTP in Smithy specification. We could also add validation for 204 responses to Smithy to emit a DANGER event when detected. As other things come up, they can be accounted for in our validation too.

mtdowling added a commit that referenced this issue Jun 3, 2022
And also mention that violating the HTTP spec in general is asking for a
bad time.

Closes #1244
mtdowling added a commit that referenced this issue Jun 4, 2022
And also mention that violating the HTTP spec in general is asking for a
bad time.

Closes #1244
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants