fix(core): silently skip GEMINI.md paths that are directories (EISDIR)#22852
fix(core): silently skip GEMINI.md paths that are directories (EISDIR)#22852shathwik30 wants to merge 2 commits intogoogle-gemini:mainfrom
Conversation
When a directory named GEMINI.md exists in the project tree, fs.access() succeeds (directories are readable), so the path is added to the discovery list. The subsequent fs.readFile() then throws EISDIR, which was previously caught and emitted as a logger.warn(), surfacing a noisy warning for a completely valid project structure. Apply the EAFP pattern: detect the EISDIR error code in readGeminiMdFiles and demote it to a debug-level log, silently returning null content for that path. All other errors continue to be warned as before. Add a unit test that creates a GEMINI.md directory alongside real files and asserts that loadServerHierarchicalMemory returns empty content without throwing. Fixes google-gemini#16282 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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 refines the memory discovery process by introducing robust error handling for 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 effectively addresses a bug where a directory named GEMINI.md would cause an EISDIR error and generate a confusing warning. The fix correctly identifies this specific error code and handles it gracefully by skipping the warning. The addition of a dedicated unit test is a great way to ensure this fix is robust and prevents future regressions. The suggestion to improve the type safety of the error checking logic is valid and has been retained.
|
I have read the CLA Document and I hereby sign the CLA |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
Hi @shathwik30, this PR is being closed due to test failures and 23 days of inactivity. To keep the review queue manageable, we are closing stale blocked PRs. Please feel free to re-open this PR or open a new one once the issues are resolved! Thank you for your contribution. |
When a directory named GEMINI.md exists in the workspace tree, the memory discovery process previously logged a confusing 'Could not read GEMINI.md' warning because fs.readFile throws EISDIR on directories. Directories with that name are valid in some project structures and should simply be ignored. Detect EISDIR specifically in the readGeminiMdFiles catch block and skip silently with a debug log, while preserving the warning behaviour for genuinely unexpected read errors. Adds two tests: - a direct readGeminiMdFiles test asserting null content (no throw) when given a directory path - an end-to-end loadServerHierarchicalMemory test asserting empty memory when a GEMINI.md directory is present in the workspace Fixes google-gemini#16282 Supersedes google-gemini#22852 (closed due to test failures and inactivity); the production fix here uses the same NodeJS.ErrnoException type guard that gemini-code-assist suggested on that PR, with fresh tests written from scratch against the current code.
Summary
Fixes #16282
When a directory named
GEMINI.mdexists anywhere in the project tree,fs.access()succeeds (directories are readable), so the path gets added to the memory discovery list. The subsequentfs.readFile()call then throwsEISDIR, which was previously caught and emitted as alogger.warn()— surfacing a confusing warning for a completely valid project structure.Root cause
In
readGeminiMdFiles, the catch block treated all read errors equally, forwarding them tologger.warn. AnEISDIRerror is not an unexpected failure — it simply means a directory exists where a file was expected, and the right action is to skip it silently.Fix
Applied the EAFP pattern inside
readGeminiMdFiles(packages/core/src/utils/memoryDiscovery.ts): detect theEISDIRerror code and demote it to adebugLogger.debugcall, silently returningnullcontent for that path. All other error types continue to produce alogger.warnas before.Test plan
should silently skip a GEMINI.md path that is a directory (EISDIR)unit test — creates aGEMINI.md/directory in the workspace and asserts thatloadServerHierarchicalMemoryreturns empty content without throwing or warningmemoryDiscovery.test.tspass🤖 Generated with Claude Code