Skip to content

fix(core): fail session deletion when file is missing#26184

Closed
haosenwang1018 wants to merge 1 commit into
google-gemini:mainfrom
haosenwang1018:fix/session-delete-missing-file
Closed

fix(core): fail session deletion when file is missing#26184
haosenwang1018 wants to merge 1 commit into
google-gemini:mainfrom
haosenwang1018:fix/session-delete-missing-file

Conversation

@haosenwang1018

Copy link
Copy Markdown
Contributor

Summary

Fixes #26113.

When session deletion cannot find a matching session file, ChatRecordingService.deleteSession() currently resolves successfully. The interactive /resume browser treats that as a successful deletion and removes the row from UI state even though the .jsonl file remains on disk.

This changes deletion to fail fast when the chats directory exists but no matching session file is found, so callers can surface the error instead of optimistically hiding the session.

Test plan

  • npm test --workspace @google/gemini-cli-core -- chatRecordingService.test.ts
  • npm run typecheck --workspace @google/gemini-cli-core
  • npx prettier --check packages/core/src/services/chatRecordingService.ts packages/core/src/services/chatRecordingService.test.ts

@haosenwang1018 haosenwang1018 requested a review from a team as a code owner April 29, 2026 10:22
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 improves the reliability of the session deletion process by ensuring that the system explicitly fails when a session file cannot be located. By moving away from silent success, the application can now correctly handle scenarios where the UI state might be out of sync with the underlying file system, allowing for better error reporting and user feedback.

Highlights

  • Error Handling Improvement: Updated the session deletion logic to throw an error if no matching session file is found, preventing silent failures.
  • Test Suite Update: Modified the test case to verify that an error is correctly thrown when attempting to delete a non-existent session.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the deleteSession method in chatRecordingService.ts to throw an error when no matching session files are found, with corresponding updates to the test suite. Feedback highlights that this change breaks the idempotency of the deletion operation and introduces inconsistent behavior, as the method still returns successfully if the underlying directory is missing.

Comment on lines +698 to +700
if (matchingFiles.length === 0) {
throw new Error(`No session file found for ${sessionIdOrBasename}`);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This change breaks the idempotency of the deleteSession method and introduces inconsistent behavior regarding the 'session not found' state.

  1. Inconsistency: If the chats directory is missing, the method returns successfully (line 691). However, if the directory exists but no matching session file is found, it now throws an error. This makes the result of deleting a non-existent session dependent on whether other sessions have been created or if the directory was manually initialized.
  2. Idempotency: Standard delete operations are typically idempotent. Throwing an error when a session is already deleted (or never existed) can cause issues for callers or UI logic that expects a successful outcome if the target resource is absent. If a user or script calls delete twice, the second call will now fail.
  3. Subagent Deletion: Subagent files are stored in subdirectories and do not use the session- prefix (see line 404). Because getMatchingSessionFiles only searches the top-level directory and filters for the prefix, it will never find subagent files. Attempting to delete a subagent session directly will now result in a hard error instead of a silent no-op, which may prevent the UI from cleaning up stale entries if it allows individual subagent deletion.

Consider whether the 'not found' case should remain a successful no-op to maintain idempotency, or if the search logic should be expanded to be more inclusive before failing.

Bojun-Vvibe added a commit to Bojun-Vvibe/oss-contributions that referenced this pull request Apr 29, 2026
…(5 PRs)

- BerriAI/litellm#26764 merge-after-nits: multipart user_config/tags JSON decode
- BerriAI/litellm#26769 request-changes: FuturMix add bundles unrelated deletions
- google-gemini/gemini-cli#26184 merge-after-nits: deleteSession fail-loud on missing file
- QwenLM/qwen-code#3737 merge-after-nits: drop strip-thoughts helpers, preserve reasoning_content
- aaif-goose/goose#8781 needs-discussion: ACP per-connection inline→spawn ordering question
@gemini-cli

gemini-cli Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Hi there! Thank you for your interest in contributing to Gemini CLI.

To ensure we maintain high code quality and focus on our prioritized roadmap, we only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'.

This PR will be closed in 7 days if it remains without that designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding.

@gemini-cli gemini-cli Bot added priority/p2 Important but can be addressed in a future release. area/core Issues related to User Interface, OS Support, Core Functionality labels May 7, 2026
@gemini-cli

gemini-cli Bot commented May 14, 2026

Copy link
Copy Markdown
Contributor

This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding.

@gemini-cli gemini-cli Bot closed this May 14, 2026
@sripasg sripasg added the size/s A small PR label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality priority/p2 Important but can be addressed in a future release. size/s A small PR status/pr-nudge-sent

Projects

None yet

2 participants