Skip to content

chore: add Value depth level guard#15778

Merged
diegomarquezp merged 14 commits intogoogleapis:mainfrom
diegomarquezp:bigtable-sql/value-recurse-guard
Dec 2, 2025
Merged

chore: add Value depth level guard#15778
diegomarquezp merged 14 commits intogoogleapis:mainfrom
diegomarquezp:bigtable-sql/value-recurse-guard

Conversation

@diegomarquezp
Copy link
Copy Markdown
Contributor

  • chore: add Value depth level guard
  • chore: add tests

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @diegomarquezp, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a crucial safeguard to the google::cloud::bigtable::Value class by implementing a recursion depth limit during type validation. This change addresses potential issues with excessively deep nested Value objects, such as arrays of arrays or deeply structured maps, which could lead to stack overflows or performance degradation. By capping the recursion at 10 levels, the system becomes more robust against malformed or overly complex data structures without impacting typical use cases.

Highlights

  • Recursion Depth Guard: Implemented a depth limit of 10 levels for nested Value type validation to prevent stack overflows and excessive resource usage.
  • Enhanced Type Matching Functions: Modified TypeAndValuesMatch and its recursive helpers (TypeAndArrayValuesMatch, TypeAndMapValuesMatch, TypeAndStructValuesMatch) to track and enforce the nesting depth.
  • Comprehensive Testing: Added new test cases to value_test.cc specifically to verify the depth guard's functionality, ensuring that values exceeding the limit are correctly rejected and valid deeply nested values are accepted.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

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

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 introduces a depth guard to prevent stack overflows from deeply nested Value objects, which is a valuable defensive programming measure. The implementation correctly adds a depth parameter to the recursive validation functions and performs the necessary checks. Additionally, the tests have been improved to be more specific about error messages, and a new test case for the depth limit has been added. I have two suggestions for improvement: one to address duplicated code which violates the repository's style guide, and another to correct a confusing error message that appears to be a copy-paste error.

Comment thread google/cloud/bigtable/value.cc Outdated
Comment thread google/cloud/bigtable/value.cc
@diegomarquezp diegomarquezp marked this pull request as ready for review November 18, 2025 22:04
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 18, 2025

Codecov Report

❌ Patch coverage is 96.20253% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.94%. Comparing base (45fe5af) to head (a30afa5).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
google/cloud/bigtable/value.cc 88.88% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15778   +/-   ##
=======================================
  Coverage   92.94%   92.94%           
=======================================
  Files        2454     2454           
  Lines      226878   226919   +41     
=======================================
+ Hits       210879   210921   +42     
+ Misses      15999    15998    -1     

☔ View full report in Codecov by Sentry.
📢 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.

Comment thread google/cloud/bigtable/value.cc Outdated
Comment thread google/cloud/bigtable/value.cc Outdated
Comment thread google/cloud/bigtable/value.h Outdated
Comment thread google/cloud/bigtable/value.cc Outdated
scotthart
scotthart previously approved these changes Nov 20, 2025
Comment thread google/cloud/bigtable/value.cc Outdated
Comment thread google/cloud/bigtable/value.cc Outdated
Comment thread google/cloud/bigtable/value.cc Outdated
@diegomarquezp diegomarquezp merged commit d6aff23 into googleapis:main Dec 2, 2025
68 of 70 checks passed
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