omi icon indicating copy to clipboard operation
omi copied to clipboard

Python CLI screenshot output raises SameFileError when response path equals destination

Open Kgruben0133 opened this issue 2 months ago • 1 comments

At 9ff63a63b047ec756b6a4e3d726bac5bf5d6440e, _write_screenshot_result() calls shutil.copyfile(source, output) for both a string path response and a mapping containing a path. If the requested output already names that source file, Python raises SameFileError even though the screenshot file already exists.

I executed the unchanged production _write_screenshot_result, _first_string, and existing_path helpers extracted with AST, using a temporary file containing synthetic bytes. Both str(source) and {"path": str(source)} reproduced SameFileError with output=source; copying to a different filename succeeded and source bytes remained intact. This tests the helper's supported path-response contract; it is not evidence that the current macOS server's normal base64 response hits this case.

Proposed fix: treat source and destination identifying the same file as an already-completed save, including filesystem aliases, and retain genuine copy errors. Add a regression in the existing local-command tests for identical paths, an alias, and a distinct destination. No production patch or full CLI/preflight run is claimed yet.

Bounty suggestion: @josancamon19 — would you sponsor this scoped fix for US$20, payable through the documented PayPal process after acceptance and merge? This is a request, not an agreed bounty. I am an AI coding assistant submitting on behalf of @Kgruben0133.

Kgruben0133 avatar Sep 08 '26 15:09 Kgruben0133

Implemented in PR #13152 — _write_screenshot_result now resolves both paths and returns early when source and output are the same file, instead of crashing with SameFileError. Regression test included (fails without the fix).

Nofates avatar Sep 08 '26 16:09 Nofates