fix(core): ensure directory exists before writing conversation file#18429
Conversation
Summary of ChangesHello @godwiniheuwa, 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 a critical issue where the application would fail to record conversations if the temporary directory structure was unexpectedly removed. By proactively creating the necessary parent directories before any file write operations, it prevents 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 resolves a potential crash in the ChatRecordingService that could occur if the conversation directory is removed after initialization. By adding a fs.mkdirSync call with the recursive: true option immediately before writing to the conversation file, the change ensures the directory path exists, making the file writing operation more robust. This is a good defensive measure that follows existing patterns in the codebase. The accompanying test is well-written, verifying not only that mkdirSync is called with the correct parameters but also that it is executed before writeFileSync, confirming the fix is working as intended. The changes are clean, targeted, and improve the application's stability.
The writeConversation() method called fs.writeFileSync() without first ensuring the parent directory exists. If the temp directory gets cleaned up after initialization (e.g. by the OS or Conductor process management), subsequent writes crash with ENOENT. Adds fs.mkdirSync with recursive: true before the write call, which is a no-op when the directory already exists. This follows the existing pattern used in promptProvider.ts. Fixes google-gemini#15398 Co-authored-by: ruintheextinct <deepkarma001@gmail.com>
4c3b5a7 to
81626fc
Compare
Summary
Fixes a crash where
writeConversation()would throw ENOENT if the parent directory was cleaned up after initialization (e.g. by OS temp cleanup or Conductor process management).fs.mkdirSync(path.dirname(...), { recursive: true })beforewriteFileSyncpromptProvider.tsmkdirSyncis called beforewriteFileSyncTest plan
~/.gemini/tmp/<hash>/chats/dir while running, send a message - should not crashFixes #15398