Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the DirectPath and CloudPath options configuration to properly respect the universe domain option and the GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable, moving the setup functions to defaults.cc and adding corresponding unit tests. The review identified a critical use-after-move bug in DirectPathProber::Probe where probe_options is moved inside an if block but subsequently accessed. Additionally, several unit tests in directpath_prober_test.cc contain weak assertions wrapped in conditional checks that should be simplified to assert directly using testing::Optional.
| std::string const& peer_address, | ||
| std::shared_ptr<grpc::AuthContext const> const& auth_context) { | ||
| std::shared_ptr<BigtableStub> effective_stub = stub; | ||
| Options probe_options = options; |
There was a problem hiding this comment.
Declaring probe_options outside the if block and then using it after the block (e.g., at lines 150 and 166) introduces a use-after-move bug.
Inside the if (!effective_stub) block, probe_options is moved into CreateDefaultBigtableStub(auth, std::move(probe_options)) (which is called right after line 137). This leaves probe_options in an unspecified/empty state, so subsequent accesses to it (such as retrieving the timeout or passing it to PingAndWarm) will use empty options.
To fix this, pass probe_options by value (without std::move) to CreateDefaultBigtableStub inside the if block, as it is still needed for the subsequent PingAndWarm call.
| if (captured_authority.has_value()) { | ||
| EXPECT_THAT(captured_authority, Optional(Eq("bigtable.googleapis.com"))); | ||
| } |
There was a problem hiding this comment.
The if (captured_authority.has_value()) check makes this assertion weak. If captured_authority is std::nullopt (which would indicate a failure), the test will silently skip the assertion and pass.
Since testing::Optional already verifies that the optional contains a value, you can safely remove the if check and assert directly.
EXPECT_THAT(captured_authority, Optional(Eq("bigtable.googleapis.com")));| if (captured_authority.has_value()) { | ||
| EXPECT_THAT(captured_authority, Optional(Eq("bigtable.ud.net"))); | ||
| } |
There was a problem hiding this comment.
The if (captured_authority.has_value()) check makes this assertion weak. If captured_authority is std::nullopt (which would indicate a failure), the test will silently skip the assertion and pass.
Since testing::Optional already verifies that the optional contains a value, you can safely remove the if check and assert directly.
EXPECT_THAT(captured_authority, Optional(Eq("bigtable.ud.net")));| if (captured_authority.has_value()) { | ||
| EXPECT_THAT(captured_authority, Optional(Eq("bigtable.ud-env-var.net"))); | ||
| } |
There was a problem hiding this comment.
The if (captured_authority.has_value()) check makes this assertion weak. If captured_authority is std::nullopt (which would indicate a failure), the test will silently skip the assertion and pass.
Since testing::Optional already verifies that the optional contains a value, you can safely remove the if check and assert directly.
EXPECT_THAT(captured_authority, Optional(Eq("bigtable.ud-env-var.net")));
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16704 +/- ##
==========================================
+ Coverage 92.74% 92.76% +0.01%
==========================================
Files 2271 2271
Lines 227219 227478 +259
==========================================
+ Hits 210734 211018 +284
+ Misses 16485 16460 -25 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
No description provided.