add content info when validate tool paras' schema error#729
add content info when validate tool paras' schema error#729sinberCS wants to merge 2 commits intoagentscope-ai:mainfrom
Conversation
Change-Id: Ib2b920ace1e76356737b2915db72e966f9e42a74
Summary of ChangesHello @sinberCS, 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 significantly enhances the debugging experience for developers working with tools by providing more informative error messages. When tool parameters fail schema validation, the error message will now include the actual content that was passed, making it much easier to diagnose and correct parameter-related issues. This directly addresses issue #727, as demonstrated by the 'before' and 'after' images in the PR description. Highlights
Changelog
Activity
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 enhances the error message for tool parameter validation failures by including the actual content that failed validation. While this is beneficial for debugging, it introduces a potential security risk by exposing raw input data in the returned error message. My review includes a suggestion to log the detailed error for debugging purposes while returning a less verbose, secure error message to the caller, mitigating the risk of sensitive data exposure.
| String errorMsg = | ||
| String.format( | ||
| "Parameter validation failed for tool '%s': %s\n" | ||
| + "Actual content: %s\n" | ||
| + "Please correct the parameters and try again.", | ||
| toolCall.getName(), validationError); | ||
| toolCall.getName(), | ||
| validationError, | ||
| toolCall.getContent()); | ||
| logger.debug(errorMsg); | ||
| return Mono.just(ToolResultBlock.error(errorMsg)); |
There was a problem hiding this comment.
Including the raw toolCall.getContent() in the error message that is returned can lead to sensitive data exposure. If the tool's input contains secrets like API keys, passwords, or personal data, they would be leaked into the ToolResultBlock, which might be propagated to other systems or logs with higher visibility than debug logs.
To mitigate this, it's better to include the Actual content only in the debug log message and not in the error message returned to the caller.
String baseError = String.format("Parameter validation failed for tool '%s': %s", toolCall.getName(), validationError);
logger.debug(baseError + "\nActual content: " + toolCall.getContent() + "\nPlease correct the parameters and try again.");
return Mono.just(ToolResultBlock.error(baseError + "\nPlease correct the parameters and try again."));Change-Id: I9ee09aa574c4e9b16f729514fad4d4d00d2cfd88
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
fix issue #727
before

after
