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.
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.
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.
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.
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 <[email protected]>
|
[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.