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

fix: httpRoute.match.prefix does not need to end in '/' #713

Conversation

conorevans
Copy link
Contributor

Issue #, if available: #712

Description of changes: Remove obligation for httpRoute.match.prefix to end in / - this does not match API behaviour.

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

@conorevans
Copy link
Contributor Author

@BennettJames @ysdongAmazon can you take a look here please?

@ysdongAmazon
Copy link
Contributor

Checked the suffix pattern only exist under gateway route validation.
In our gateway route console and SDK, true, gateway route mentioned as prefix routing instead of path-based routing. Waiting for the team to confirm if it needs to be aligned with the SDK.

I suppose the original author was trying to ensure consistency in path routing:
Prefix routing: consider two routes, one with prefix /product and another with prefix /product-special. If a request comes in with path /product-special/1234, both routes will match the request, because both prefixes are present in the path. This creates ambiguity about which route should process the request.

Path-based routing: enforced convention is applied and routes are defined with prefixes /product/ and /product-special/. With this convention, a request with path /product-special/1234 would only match the second route, eliminating the ambiguity.

@ysdongAmazon
Copy link
Contributor

ysdongAmazon commented Jul 25, 2023

Triggered unit test workflow.

wantErr: errors.New("Prefix to be matched on must start and end with '/'"),
also need to be modified

@conorevans
Copy link
Contributor Author

conorevans commented Jul 27, 2023

I suppose the original author was trying to ensure consistency in path routing:
Prefix routing: consider two routes, one with prefix /product and another with prefix /product-special. If a request comes in with path /product-special/1234, both routes will match the request, because both prefixes are present in the path. This creates ambiguity about which route should process the request.

I can see that, but it breaks a very standard case, which is just a simple /something route. Even if I don't have /something-else, then I can't use /something because it isn't /something/. When you consider that someone in that case could simply use HttpPathMatch, I don't think this safeguard makes sense. Additionally, you could even use priority on the route even if you wanted to use Prefix, e.g. Prefix /something-else with priority 1 and Prefix something with priority 2, to ensure it's evaluated first.

Will fix the unit test tomorrow!

Thanks for looking @ysdongAmazon 😄

E: I've unblocked myself using path btw, which can be regex: /myprefix$

@conorevans
Copy link
Contributor Author

@ysdongAmazon committed the test fix!

@ysdongAmazon ysdongAmazon merged commit 6d3c346 into aws:master Aug 2, 2023
3 checks passed
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