fix(core): truncate excessively long lines in grep search output#21147
fix(core): truncate excessively long lines in grep search output#21147gundermanc merged 2 commits intomainfrom
Conversation
1a51eaa to
82481a0
Compare
|
Size Change: +271 B (0%) Total Size: 26 MB ℹ️ View Unchanged
|
82481a0 to
f75844b
Compare
77770d8 to
5bc1a7c
Compare
5bc1a7c to
82a4a17
Compare
Summary of ChangesHello, 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 resolves an issue where 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 addresses a crash caused by excessively long lines in grep search results by truncating them. The implementation is mostly correct, but it uses substring for truncation, which can incorrectly handle multi-byte Unicode characters, leading to potential data corruption. I've provided a suggestion to align with the repository's guidelines for safe string truncation.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…gle-gemini#21147) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…gle-gemini#21147) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…gle-gemini#21147) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…gle-gemini#21147) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Summary
This PR fixes a "too long message" error in the CLI by truncating excessively long lines in
grep_searchresults.Details
When
grep_searchfinds matches in files with extremely long lines (e.g., minified JS, base64 strings, or large JSON blobs), the full line content was previously returned to the LLM and the UI. This could cause the CLI to hang or crash during rendering (specifically inwrap-ansi) and was inefficient for context usage.This change enforces a
MAX_LINE_LENGTH_TEXT_FILE(2000 characters) limit on lines formatted ingrep-utils.ts. Lines exceeding this limit are truncated and appended with... [truncated].Related Issues
N/A (Verified via new unit test)
How to Validate
npm test -w @google/gemini-cli-core -- src/tools/grep.test.tsshould truncate excessively long linesverifies the behavior.Pre-Merge Checklist