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: Validate paths and check additionalPathTemplates #1522

Merged
merged 4 commits into from
Mar 27, 2023

Conversation

lqiu96
Copy link
Contributor

@lqiu96 lqiu96 commented Mar 21, 2023

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:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

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.

@lqiu96 lqiu96 requested a review from blakeli0 March 21, 2023 20:01
@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Mar 21, 2023
@lqiu96 lqiu96 marked this pull request as ready for review March 21, 2023 20:32
@lqiu96 lqiu96 requested a review from a team as a code owner March 21, 2023 20:32
}
for (PathTemplate additionalPathTemplate : additionalPathTemplates) {
String additionalPath =
additionalPathTemplate.instantiate(pathVarsExtractor.extract(apiMessage));
Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@sonarqubecloud
Copy link

[gapic-generator-java-root] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@sonarqubecloud
Copy link

[java_showcase_integration_tests] SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

31.2% 31.2% Coverage
0.0% 0.0% Duplication

@sonarqubecloud
Copy link

[java_showcase_unit_tests] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@lqiu96
Copy link
Contributor Author

lqiu96 commented Mar 27, 2023

Failing for [java_showcase_integration_tests] SonarCloud Code Analysis. This new code change will be covered by the compliance proto. I plan to add it once I resolve part 2 of this issue.

The compliance proto fails because of this issue. I'll merge in for now.

@lqiu96 lqiu96 merged commit 5173014 into main Mar 27, 2023
@lqiu96 lqiu96 deleted the main-http_additional_bindings_part_1 branch March 27, 2023 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants