fix(core): handle ENAMETOOLONG in robustRealpath - #25727
Conversation
- Add ENAMETOOLONG to caught errors in robustRealpath to prevent crashes on long paths. - Add regression test case to verify fix and prevent future regressions. Fixes #25696
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 unhandled promise rejection in the CLI that occurred when the application attempted to process extremely long strings as file paths. By explicitly including ENAMETOOLONG in the error handling logic of the path resolution utility, the application now correctly identifies these cases and avoids crashing, ensuring a more robust user experience. 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. Footnotes
|
|
Size Change: +63 B (0%) Total Size: 33.7 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Code Review
This pull request updates the robustRealpath utility in packages/core to handle ENAMETOOLONG errors. Previously, the function only explicitly handled ENOENT and EISDIR errors. By adding ENAMETOOLONG to the error handling logic, the utility now correctly falls back or returns the path as-is when encountering extremely long file paths, preventing unhandled exceptions. A corresponding unit test has been added to verify this behavior by mocking filesystem errors. I have no feedback to provide.
|
This item has been automatically marked as stale due to 60 days of inactivity. It will be closed in 14 days if no further activity occurs. Thank you! |
|
This item has been closed due to 14 additional days of inactivity after being marked as stale. If you believe this is still relevant, feel free to comment or reopen. Thank you! |
Summary
Fixes a crash (Unhandled Promise Rejection) in the CLI when processing extremely long strings (like large Python code snippets) as potential file paths. The crash occurred because the
ENAMETOOLONGerror from the file system was not being caught in therobustRealpathfunction.Details
robustRealpathinpackages/core/src/utils/paths.tsto catchENAMETOOLONGin addition toENOENTandEISDIR.@pathcommand but is too long to be a valid path, the CLI gracefully ignores it instead of crashing.packages/core/src/utils/paths.test.tsto mock this scenario and prevent regressions.Related Issues
Fixes #25696
How to Validate
npm run build -w @google/gemini-cli-core.npm run startand paste a long quoted string (e.g.,@"a" * 5000).npm run startand paste the same string.Pre-Merge Checklist