Skip to content

fix(bigtable): safely handle error states in metadata retrieval#16225

Open
colinmoy wants to merge 1 commit into
googleapis:mainfrom
colinmoy:fix-bigtable-metadata-safety
Open

fix(bigtable): safely handle error states in metadata retrieval#16225
colinmoy wants to merge 1 commit into
googleapis:mainfrom
colinmoy:fix-bigtable-metadata-safety

Conversation

@colinmoy

@colinmoy colinmoy commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Fixes a potential undefined behavior/crash where source_ (a nested std::optional<StatusOr<...>>) was being dereferenced without checking if the underlying StatusOr holds an error

fixes #16222

@colinmoy colinmoy requested a review from a team as a code owner June 30, 2026 18:27
@product-auto-label product-auto-label Bot added the api: bigtable Issues related to the Bigtable API. label Jun 30, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request contains unresolved git conflict markers in google/cloud/bigtable/internal/data_connection_impl.cc within the Metadata() method. The reviewer correctly identified this issue, which would cause compilation to fail, and provided a clear suggestion to resolve the conflict by keeping the absl::optional signature while incorporating the new safety check.

Comment on lines +1009 to +1015
<<<<<<< Updated upstream
absl::optional<google::bigtable::v2::ResultSetMetadata> Metadata() override {
if (!source_.has_value()) return absl::nullopt;
=======
std::optional<google::bigtable::v2::ResultSetMetadata> Metadata() override {
if (!source_.has_value() || !source_->ok()) return std::nullopt;
>>>>>>> Stashed changes

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

Unresolved git conflict markers are present in the code. This will cause compilation to fail. Please resolve the conflict by keeping the absl::optional signature (as required by the base class override) while incorporating the safety check for !source_->ok().

  absl::optional<google::bigtable::v2::ResultSetMetadata> Metadata() override {
    if (!source_.has_value() || !source_->ok()) return absl::nullopt;
References
  1. Prefer defensive code, such as explicit ok() checks, even if they seem redundant based on the current implementation of a framework, as the framework's contract may change in the future.

@colinmoy colinmoy force-pushed the fix-bigtable-metadata-safety branch from eb58205 to b6f1f5e Compare June 30, 2026 18:36
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.24%. Comparing base (e0b2850) to head (b6f1f5e).
⚠️ Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
...le/cloud/bigtable/internal/data_connection_impl.cc 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16225      +/-   ##
==========================================
- Coverage   92.24%   92.24%   -0.01%     
==========================================
  Files        2265     2265              
  Lines      210126   210126              
==========================================
- Hits       193839   193829      -10     
- Misses      16287    16297      +10     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigtable Issues related to the Bigtable API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bigtable DataConnectionImpl::Metadata could dereference non-OK StatusOr

2 participants