chore(tools/bigtable,tools/cassandra,tools/clickhouse): decouple config from tool#2061
Conversation
Summary of ChangesHello @Yuan325, 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 significant architectural improvement by decoupling the configuration of various data source tools (Bigtable, Cassandra, ClickHouse) from their underlying client instances. This change centralizes the management and retrieval of data source clients through a Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request does a great job of decoupling the tool implementations from their configurations by moving the source retrieval logic into the Invoke method. This is a solid refactoring that improves modularity. I've found a critical compilation issue in the ClickHouse tools due to function redeclaration, and a critical security vulnerability (SQL injection). I've also included a suggestion to reduce code duplication across the Invoke methods.
| if !ok { | ||
| return nil, fmt.Errorf("unable to retrieve source %s in tool %s", t.Source, t.Name) | ||
| } | ||
| source, ok := s.(compatibleSource) |
There was a problem hiding this comment.
Do we only have a compatible source check on invoke? When Toolbox starts up it should ensure compatibility.
There was a problem hiding this comment.
@averikitsch Yes. In cases where user adds the tool before adding the source, we don't want the server to fail. (that way the initialization of tool does not depend on the source).
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request effectively decouples tool implementations from their source configurations by deferring source retrieval to the Invoke method. This is a solid architectural improvement that enhances modularity. The change to the Tool interface, allowing RequiresClientAuthorization to return an error, is well-handled in both the API and MCP layers. My review includes suggestions to improve error handling consistency and to make error messages more descriptive for better debuggability of configuration issues.
b297a57 to
67277c3
Compare
…ig from tool (#2061) ## Description Within Invoke() and RequiresClientAuthorization(), get Source from ResourceManager and use it to call functions directly. ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [ ] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) 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) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #<issue_number_goes_here>
…ig from tool (#2061) ## Description Within Invoke() and RequiresClientAuthorization(), get Source from ResourceManager and use it to call functions directly. ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [ ] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) 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) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #<issue_number_goes_here>
…ig from tool (#2061) ## Description Within Invoke() and RequiresClientAuthorization(), get Source from ResourceManager and use it to call functions directly. ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [ ] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) 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) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #<issue_number_goes_here>
…ig from tool (#2061) ## Description Within Invoke() and RequiresClientAuthorization(), get Source from ResourceManager and use it to call functions directly. ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [ ] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) 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) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #<issue_number_goes_here>
Description
Within Invoke() and RequiresClientAuthorization(), get Source from ResourceManager and use it to call functions directly.
PR Checklist
CONTRIBUTING.md
bug/issue
before writing your code! That way we can discuss the change, evaluate
designs, and agree on the general idea
!if this involve a breaking change🛠️ Fixes #<issue_number_goes_here>