-
Notifications
You must be signed in to change notification settings - Fork 220
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
What is the matching behavior with regards to empty URI path segments? #1024
Comments
Allowing labels to be empty can be problematic if the segment is at the end of a URI. S3 is the prime example of this because the URI for
Philosophically that's not an empty segment, but a All in all I think allowing empty path segments is a footgun, and disallowing them is a good thing. All that said, stripping empty path segments is probably a very bad idea. Turning |
I agree that allowing empty path segments may inadvertently cause bad API design, but the Smithy spec does not disallow them. Perhaps Smithy CLI could emit a warning if it detects a string bound with Even if the Smithy spec disallowed them for clients, the spec should clarify what servers should do when encountering empty path segments. If they don't strip them away before extracting labels, then servers will have to assign empty strings to the input fields bound to those segments, right? Is there another alternative? |
Yeah they would have to equate to empty strings. |
To clarify what we'd like to do, a case to think through is: if a client sends a request |
@gosar Yes, I think that should be the behavior, trailing slashes have meaning. It is also consistent with how websites serve HTML documents e.g. |
In #996 [0], we realized that we were ignoring empty URI path segments when doing label extraction. It turns out we are also ignoring them when doing routing, as the TypeScript sSDK currently does [1], from which the initial implementation was copied. However, a discussion with the Smithy team in smithy-lang/smithy#1024 [2] revealed that we _must not_ ignore empty URI path segments when routing or doing label extraction, since empty strings (`""`) should be assigned to the labels in those segments. This commit fixes the behavior so that we don't ignore empty path segments _when doing routing_. #996 will take care of fixing the behavior when doing label extraction. [0]: #996 (comment) [1]: https://github.com/awslabs/smithy-typescript/blob/d263078b81485a6a2013d243639c0c680343ff47/smithy-typescript-ssdk-libs/server-common/src/httpbinding/mux.ts#L78 [2]: smithy-lang/smithy#1024
…ng (#1029) In #996 [0], we realized that we were ignoring empty URI path segments when doing label extraction. It turns out we are also ignoring them when doing routing, as the TypeScript sSDK currently does [1], from which the initial implementation was copied. However, a discussion with the Smithy team in smithy-lang/smithy#1024 [2] revealed that we _must not_ ignore empty URI path segments when routing or doing label extraction, since empty strings (`""`) should be assigned to the labels in those segments. This commit fixes the behavior so that we don't ignore empty path segments _when doing routing_. #996 will take care of fixing the behavior when doing label extraction. [0]: #996 (comment) [1]: https://github.com/awslabs/smithy-typescript/blob/d263078b81485a6a2013d243639c0c680343ff47/smithy-typescript-ssdk-libs/server-common/src/httpbinding/mux.ts#L78 [2]: smithy-lang/smithy#1024
… when routing (#1029) In #996 [0], we realized that we were ignoring empty URI path segments when doing label extraction. It turns out we are also ignoring them when doing routing, as the TypeScript sSDK currently does [1], from which the initial implementation was copied. However, a discussion with the Smithy team in smithy-lang/smithy#1024 [2] revealed that we _must not_ ignore empty URI path segments when routing or doing label extraction, since empty strings (`""`) should be assigned to the labels in those segments. This commit fixes the behavior so that we don't ignore empty path segments _when doing routing_. #996 will take care of fixing the behavior when doing label extraction. [0]: smithy-lang/smithy-rs#996 (comment) [1]: https://github.com/awslabs/smithy-typescript/blob/d263078b81485a6a2013d243639c0c680343ff47/smithy-typescript-ssdk-libs/server-common/src/httpbinding/mux.ts#L78 [2]: smithy-lang/smithy#1024
I've just stumbled upon a routing issue caused by allowing empty path segments. Consider the S3-like model with two operations:
And consider the request However, in this scenario it's clear that it should be routed to |
Yeah, this is the S3 issue I mentioned before and is one of the primary motivating factors of why I don't think empty path segments should be allowed |
… when routing (#1029) In #996 [0], we realized that we were ignoring empty URI path segments when doing label extraction. It turns out we are also ignoring them when doing routing, as the TypeScript sSDK currently does [1], from which the initial implementation was copied. However, a discussion with the Smithy team in smithy-lang/smithy#1024 [2] revealed that we _must not_ ignore empty URI path segments when routing or doing label extraction, since empty strings (`""`) should be assigned to the labels in those segments. This commit fixes the behavior so that we don't ignore empty path segments _when doing routing_. #996 will take care of fixing the behavior when doing label extraction. [0]: smithy-lang/smithy-rs#996 (comment) [1]: https://github.com/awslabs/smithy-typescript/blob/d263078b81485a6a2013d243639c0c680343ff47/smithy-typescript-ssdk-libs/server-common/src/httpbinding/mux.ts#L78 [2]: smithy-lang/smithy#1024
Currently,
null
strings, as prescribed by@required
).This behavior matches what we anecdotally see when visiting most websites, e.g. these URLs behave the same as if their empty path segments were removed:
While this behavior might be perceived as intuitive, it makes it impossible for someone to call a service and assign an empty string to a field that is bound to an
@httpLabel
. Consider the URI pattern/foo/{label}/bar
and the request with URI path/foo//bar
. Here the server should assign""
tolabel
, but if it strips away empty path segments prior to routing the request, the request would be outright rejected.I think the Smithy spec should explicitly call out the behavior in the specification, since it currently does not prescribe what to do in this scenario (and I would therefore interpret it as the default, which would be to not strip away empty path segments), yet at least three implementers have independently decided to strip away empty path segments.
Some other data points to have in mind:
The text was updated successfully, but these errors were encountered: