-
Notifications
You must be signed in to change notification settings - Fork 12.1k
fix(core): handle EISDIR error when GEMINI.md is a directory #17840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -270,6 +270,16 @@ async function readGeminiMdFiles( | |
|
|
||
| return { filePath, content: processedResult.content }; | ||
| } catch (error: unknown) { | ||
| const errorCode = | ||
| typeof error === 'object' && error !== null && 'code' in error | ||
| ? (error as NodeJS.ErrnoException).code | ||
| : undefined; | ||
| if (errorCode === 'EISDIR') { | ||
| if (debugMode) { | ||
| logger.debug(`Skipping directory at ${filePath}`); | ||
| } | ||
| return { filePath, content: null }; | ||
|
Comment on lines
+277
to
+281
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returning To ensure accuracy, // In loadServerHierarchicalMemory...
const successfullyReadFiles = contentsWithPaths.filter(
(item) => item.content !== null
);
return {
memoryContent: combinedInstructions,
fileCount: successfullyReadFiles.length, // This is more accurate
filePaths,
};Since this is outside the current diff, I'm noting it here for you to consider as part of a complete fix. |
||
| } | ||
| const isTestEnv = | ||
| process.env['NODE_ENV'] === 'test' || process.env['VITEST']; | ||
| if (!isTestEnv) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make this test more robust and ensure the
fileCountis accurate, please also assert thatresult.fileCountis 0. This verifies that skipped directories are not counted as loaded files. This change is related to the suggested fix inmemoryDiscovery.tsto calculatefileCountmore accurately.