fix(cli): fall back for oversized bug report URLs#27591
Conversation
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 addresses an issue where bug reports containing large amounts of data (such as logs or extensive problem descriptions) could cause crashes or failures due to URL length limitations in certain environments like Android/Termux. By introducing a local file fallback, the system ensures that the full report content is preserved while still allowing the user to initiate the issue submission process via a shortened URL. 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 the 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 counterproductive. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to handle oversized bug reports in the bug command by writing reports that exceed the URL length limit to a local markdown file and providing a fallback URL. The review feedback recommends a security improvement: using mkdtempSync from node:fs to create uniquely and securely named temporary directories in global temp locations to prevent symlink attacks, along with corresponding updates to the unit tests.
| MEMORY_SNAPSHOT_AUTO_THRESHOLD_BYTES, | ||
| } from '../utils/memorySnapshot.js'; | ||
| import { stat } from 'node:fs/promises'; | ||
| import { stat, writeFile } from 'node:fs/promises'; |
There was a problem hiding this comment.
Import mkdtempSync from node:fs to securely create a temporary directory, and keep stat and writeFile from node:fs/promises.
| import { stat, writeFile } from 'node:fs/promises'; | |
| import { mkdtempSync } from 'node:fs'; | |
| import { stat, writeFile } from 'node:fs/promises'; |
References
- When creating temporary files or directories in global temporary directories (e.g.,
/tmp), usefs.mkdtempSync()to generate securely named, uniquely named temporary directories. This mitigates symlink attacks where an attacker could pre-create a symlink with a predictable name to truncate arbitrary files. - Use the
node:prefix when importing built-in Node.js modules for consistency across the codebase.
| await writeFile( | ||
| bugReportFilePath, | ||
| formatBugReportFile(bugDescription, info, problemValue), | ||
| 'utf8', | ||
| ); |
There was a problem hiding this comment.
When creating temporary directories in global temporary directories (e.g., /tmp), use mkdtempSync to generate securely named, uniquely named temporary directories. This mitigates symlink attacks where an attacker could pre-create a symlink with a predictable name to truncate arbitrary files.
| await writeFile( | |
| bugReportFilePath, | |
| formatBugReportFile(bugDescription, info, problemValue), | |
| 'utf8', | |
| ); | |
| const tempDir = mkdtempSync(path.join(os.tmpdir(), 'gemini-')); | |
| const bugReportFilePath = path.join(tempDir, 'bug-report.txt'); | |
| await writeFile( | |
| bugReportFilePath, | |
| formatBugReportFile(bugDescription, info, problemValue), | |
| 'utf8', | |
| ); |
References
- When creating temporary files or directories in global temporary directories (e.g.,
/tmp), usefs.mkdtempSync()to generate securely named, uniquely named temporary directories. This mitigates symlink attacks where an attacker could pre-create a symlink with a predictable name to truncate arbitrary files.
| return { | ||
| ...actual, | ||
| stat: vi.fn().mockResolvedValue({ size: 4096 }), | ||
| writeFile: vi.fn().mockResolvedValue(undefined), |
4d952ec to
93341d4
Compare
|
Pushed Change:
Validation:
|
Summary
Fix
/bugfor oversized GitHub issue URLs.The command currently encodes the title, client info, and full problem description into a single issue-template URL. On Android/Termux, that can exceed the deep-link/intent limit and crash or fail before the user can submit the report.
This keeps the normal short-report path unchanged, but when the generated URL is too large it writes the full report to a local markdown file and opens a short GitHub issue URL instead.
Changes
bug-report-<timestamp>.mdunder the project temp dirTo verify
npm run generate npm run build --workspace @google/gemini-cli-core npm run build --workspace @google/gemini-cli-devtools npm run test --workspace @google/gemini-cli -- src/ui/commands/bugCommand.test.ts npm run typecheck --workspace @google/gemini-cli npx eslint packages/cli/src/ui/commands/bugCommand.ts packages/cli/src/ui/commands/bugCommand.test.ts --max-warnings 0 npx prettier --check packages/cli/src/ui/commands/bugCommand.ts packages/cli/src/ui/commands/bugCommand.test.ts git diff --checkFixes #27590