-
Notifications
You must be signed in to change notification settings - Fork 54
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: Validate paths and check additionalPathTemplates #1522
Conversation
} | ||
for (PathTemplate additionalPathTemplate : additionalPathTemplates) { | ||
String additionalPath = | ||
additionalPathTemplate.instantiate(pathVarsExtractor.extract(apiMessage)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is pathVarsExtractor.extract(apiMessage)
expected to return different values each time?
If not, please save the result to a local variable in the first line of this method rather than repeating this call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, will update! I was prototyping with part 2 which has pathVarsExtractor.extract(apiMessage)
return different values each time.
return additionalPath; | ||
} | ||
} | ||
throw new IllegalArgumentException("No matching paths for Request: " + apiMessage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was it silently failing before? If it was, throwing an exception now could be considered a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it would making a request to the invalid URL and would result in a 404. I can update this return the default path's raw string instead of the exception.
...ava/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ProtoMessageRequestFormatter.java
Outdated
Show resolved
Hide resolved
…n/ProtoMessageRequestFormatter.java Co-authored-by: Blake Li <blakeli@google.com>
[gapic-generator-java-root] Kudos, SonarCloud Quality Gate passed! |
[java_showcase_integration_tests] SonarCloud Quality Gate failed. |
[java_showcase_unit_tests] Kudos, SonarCloud Quality Gate passed! |
Failing for The compliance proto fails because of this issue. I'll merge in for now. |
Thank you for opening a Pull Request! For general contributing guidelines, please refer to contributing guide
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Part of #1440
We validate that the default path or any additional path matches. Otherwise, it is possible to have an invalid path returned and will result in a 404 when making the call.