-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Support additional URI Template Levels #1019
Comments
Feign does it's best to adhere to RFC 6570 - Uri Templates which states:
Given this, Feign treats With that said, the specification does have support for your use case via Path Segment Expansion, which is consider a Level 3 expansion. Feign currently supports Level 1 or simple expansion at this time. With all of that, the behavior you are seeing is expected. |
I second the concerns raised by @ddoubleday and am facing the same issues that he has enumerated above. Is it in the Feign roadmap to support these use cases and in effect correct this unintended behavior via support for level 3 path segment expansion or otherwise? |
I think that we should have support for all template levels. We are open contributions to this end if any one is interested and would welcome the help. I have a working implementation in our feignx project that I am planning on back-porting, but I do not have a definitive timeframe on when that will be complete. |
I've marked this as needing votes. If we get enough interest, we can move this out of proposal state and into an enhancement state. |
All respect to you folks, but I don't think the renaming of this issue from "null should not be resolved in URITemplate" to "support additional URI Template Levels" actually fairly represents the problem. It should NEVER be acceptable to replace path components with an empty string, whether you support Level 3 expansion or not. I guess another way to say this is that you have a serious bug in your code if you AREN'T supporting an expansion process that recognizes that path variables are a special case. This issue as titled now seems like this is a "nice to have", but it really isn't. |
I agree with @ddoubleday. It should NEVER be acceptable to replace path components with an empty string, whether you support Level 3 expansion or not. Please let us know when this defect is resolved. Thank you! |
Waiting on your pull request. |
good point LOL. Maybe we should start with defining the behavior that should be expected in these cases and then go from there as to who/how will fix it. @ddoubleday thoughts? |
https://tools.ietf.org/html/rfc6570#section-3.2.6 This specification states that empty values, that is zero length strings, are not considered
With regards to the original issue, since the template does not use the path syntax of
With the following results:
All of this behavior is defined in the specification and there are some test case files created and maintained by the authors here: https://github.com/uri-templates/uritemplate-test I have a compliant implementation in feignx: https://github.com/OpenFeign/feignx/tree/master/core/src/main/java/feign/template I just need find the time to port it over ⌚️ |
Is this the same issue I'm seeing when using JAXRSContract and a query-parameter "uri=http://test" It ends up as "http%3A//test" instead of the expected: "http%3A%2F%2Ftest". This seems to be because encodeSlash is false. |
In versions of Feign before 10.x, if the URI template looked like http://base/action/{arg1}/{arg2}, and null was passed as the value to arg1, the URI
http://base/action/{arg1}/somevalue
would be tried, and rejected with IllegalArgumentException. That probably wasn't the right thing to do, but NOW, the null is actually resolved, and the situation is actually worse, resulting in the URI
http://base/action//someValue
resulting in, if you are using Spring Boot 2, a "not normalized URI exception" because they are doing security scans on URIs and disallowing consecutive slashes.
Even worse, if a value is passed to arg1 and null is passed to arg 2 and it is resolved, it can map to the entirely wrong controller method as:
http://base/action/someValue/
if these are GET operations, that might get the entire list associated with someValue, instead of the intended one value "someValue2".
Shouldn't feign refuse to resolve PATH variables if the supplied argument is null, and just throw some kind of NotNullable exception?
The text was updated successfully, but these errors were encountered: