Skip to content

fix(printing): handle FileNotFoundError in edit_file diff display#72

Merged
kowyo merged 1 commit into
mainfrom
fix/printing-file-not-found-error
Jun 6, 2026
Merged

fix(printing): handle FileNotFoundError in edit_file diff display#72
kowyo merged 1 commit into
mainfrom
fix/printing-file-not-found-error

Conversation

@kowyo

@kowyo kowyo commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Description

When displaying the diff for an edit_file tool result in the session history, Path(path).read_text() would raise a FileNotFoundError if the file was deleted between the edit and the display. This wraps the read in a try/except to gracefully handle that case.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Test

Manually verified that printing a session containing an edit_file tool result for a now-deleted file no longer crashes.


Assisted-by: mini-agent:deepseek-v4-flash

When printing the diff for an edit_file tool result, reading the file
from disk could raise FileNotFoundError if the file was deleted between
the edit and the display. Wrap the read in a try/except to gracefully
handle this case.

Assisted-by: mini-agent:deepseek-v4-flash
@kowyo kowyo added the bug Something isn't working label Jun 6, 2026

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

Copy link
Copy Markdown

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 wraps the file reading logic in print_tool_result with a try-except block to handle FileNotFoundError gracefully when displaying tool results. The reviewer suggests catching a broader Exception instead of just FileNotFoundError to handle other potential file access errors (such as permission or decoding issues) and prevent CLI crashes.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/mini_agent/cli/display/printing.py
@kowyo kowyo marked this pull request as ready for review June 6, 2026 09:00

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 1 file

Re-trigger cubic

@kowyo kowyo merged commit 036d64a into main Jun 6, 2026
19 checks passed
@kowyo kowyo deleted the fix/printing-file-not-found-error branch June 6, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant