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: URL encode explicit routing values #12447

Merged
merged 2 commits into from
Aug 23, 2023

Conversation

dbolduc
Copy link
Member

@dbolduc dbolduc commented Aug 23, 2023

Part of the work for #12232

Update the explicit routing matchers to url encode the values in the routing pairs.

Update the part of testing_util::ValidateMetadataFixture that computes the expected routing headers.

Then legacy bigtable also uses that testing helper, so we must update it in this PR. I separated the bigtable stuff into its own commit (hopefully) for clarity.


This change is Reviewable

@dbolduc dbolduc temporarily deployed to internal August 23, 2023 05:00 — with GitHub Actions Inactive
@dbolduc dbolduc marked this pull request as ready for review August 23, 2023 06:07
@dbolduc dbolduc requested a review from a team as a code owner August 23, 2023 06:07
@codecov
Copy link

codecov bot commented Aug 23, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.01% ⚠️

Comparison is base (d67bcb7) 93.61% compared to head (f7e2e28) 93.60%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12447      +/-   ##
==========================================
- Coverage   93.61%   93.60%   -0.01%     
==========================================
  Files        2036     2036              
  Lines      180316   180340      +24     
==========================================
+ Hits       168794   168810      +16     
- Misses      11522    11530       +8     
Files Changed Coverage Δ
...sts/golden_kitchen_sink_metadata_decorator_test.cc 99.61% <100.00%> (ø)
...olden_kitchen_sink_rest_metadata_decorator_test.cc 100.00% <100.00%> (ø)
...golden_thing_admin_rest_metadata_decorator_test.cc 100.00% <100.00%> (ø)
.../cloud/bigtable/internal/legacy_row_reader_test.cc 100.00% <100.00%> (ø)
google/cloud/bigtable/metadata_update_policy.cc 100.00% <100.00%> (ø)
...ogle/cloud/bigtable/metadata_update_policy_test.cc 100.00% <100.00%> (ø)
google/cloud/internal/routing_matcher.h 100.00% <100.00%> (ø)
google/cloud/internal/routing_matcher_test.cc 95.38% <100.00%> (+1.90%) ⬆️
google/cloud/testing_util/validate_metadata.cc 92.81% <100.00%> (ø)

... and 6 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -322,7 +322,7 @@ TEST_F(MetadataDecoratorTest, ExplicitRouting) {
// `google.api.routing` for Example 9:
//
// https://github.com/googleapis/googleapis/blob/70147caca58ebf4c8cd7b96f5d569a72723e11c1/google/api/routing.proto#L387-L390
std::string expected1 = "table_location=instances/instance_bar";
std::string expected1 = "table_location=instances%2Finstance_bar";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I was going to suggest using UrlEncode() to construct these expected strings, but them I thought, "nah, it's fine putting exactly what is expected." But then I saw that you do use UrlEncode() in other tests. Perhaps those latter cases are just because you have the unencoded string for other purposes? Anyway, perhaps worthy of a short ponder.

Copy link
Member Author

@dbolduc dbolduc Aug 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, so I didn't consider that. Now that I am considering it, I think I ever so slightly prefer the code the way it is.

We do not URL encode the =, so it would look like:

auto expected1 = "table_location=" + internal::UrlEncode("instances/instance_bar");

or really...

auto expected1 = internal::UrlEncode("table_location") + "=" + internal::UrlEncode("instances/instance_bar");

.... meh

@dbolduc dbolduc merged commit afba817 into googleapis:main Aug 23, 2023
52 checks passed
@dbolduc dbolduc deleted the url-encode-explicit-routing-values branch August 23, 2023 17:17
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.

3 participants