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

aws-smithy-http-server: don't ignore empty path segments when routing #1029

Merged
merged 4 commits into from
Jan 12, 2022

Conversation

david-perez
Copy link
Contributor

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.

Testing

Test suite has been expanded.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

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
@david-perez david-perez requested a review from a team as a code owner January 4, 2022 15:37
@github-actions
Copy link

github-actions bot commented Jan 4, 2022

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Jan 4, 2022

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Server Test

@82marbag 82marbag mentioned this pull request Jan 5, 2022
2 tasks
@github-actions
Copy link

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Server Test

Copy link
Contributor

@crisidev crisidev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions
Copy link

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Server Test

@david-perez david-perez enabled auto-merge (squash) January 12, 2022 13:51
@github-actions
Copy link

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Server Test

@david-perez david-perez merged commit 611ebb6 into main Jan 12, 2022
@david-perez david-perez deleted the davidpz-route-conflicts branch January 12, 2022 14:07
david-perez added a commit that referenced this pull request Jan 13, 2022
…ce test

The previous commit introduced a failing test because CI doesn't have
Rust tests as a blocking step and auto-merge was enabled.

With the two operations:

1. `ListBuckets` with URI pattern `/`; and
2. `ListObjects` with URI pattern `/{bucket}`,

the test wants to route the request `/` to the first operation. However,
in #1029 we started allowing empty path segments. Since `ListBuckets`
has more weight than `ListObjects`, the request matches against it,
binding `""` to the `bucket` label.
david-perez added a commit that referenced this pull request Jan 13, 2022
…ce test (#1070)

The previous commit introduced a failing test because CI doesn't have
Rust tests as a blocking step and auto-merge was enabled.

With the two operations:

1. `ListBuckets` with URI pattern `/`; and
2. `ListObjects` with URI pattern `/{bucket}`,

the test wants to route the request `/` to the first operation. However,
in #1029 we started allowing empty path segments. Since `ListBuckets`
has more weight than `ListObjects`, the request matches against it,
binding `""` to the `bucket` label.
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 this pull request may close these issues.

2 participants