Treat a vanished entry as a miss in FileTreeStore.get_entry - #367
Treat a vanished entry as a miss in FileTreeStore.get_entry#367jonaseck2 wants to merge 1 commit into
Conversation
get_entry checks that the file exists and then opens it. If something deletes the entry in between, read_file raises FileNotFoundError and it reaches the caller. Return None instead. That is what get already returns when the file is gone at the exists() check, and what delete_entry does in the same class. The test removes the file inside the exists() call, following test_delete_returns_false_when_file_disappears_before_unlink, so the interleaving is deterministic rather than timing-dependent. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan includes up to 1 review per rolling hour; 0 remain after this review. Walkthrough
Merge Risk: ⚪ Minimal · up to This localized change treats an entry deleted during lookup as a cache miss instead of raising an error, with targeted tests and clean checks reported; no actionable merge-blocking risk remains after normal review. 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
No issues found across 2 files
Auto-approved: Focused bug fix: catches FileNotFoundError between exists() and read to return None, matching existing get/delete_entry miss semantics, with a deterministic race test. No design or operational tradeoff requires human judgment.
Re-trigger cubic
Closes #366.
get_entrychecks that the file exists and then opens it. If something deletes the entry in between,read_fileraisesFileNotFoundErrorand it reaches the caller.This returns
Noneinstead. That is whatgetalready returns when the file is gone at theexists()check, and whatdelete_entrydoes in the same class.The test removes the file inside the
exists()call, followingtest_delete_returns_false_when_file_disappears_before_unlink, so the interleaving is deterministic rather than timing-dependent.Checks on Python 3.12:
ruff formatandruff checkclean,basedpyright0 errors, and the two filetree race tests pass. Without the change instore.pythe new test fails withFileNotFoundError.Context for why this matters in practice is in #366: we hit it on FastMCP's
OAuthProxy, where one-time-use refresh tokens are deleted as part of normal rotation, and the exception turned a cache miss the caller handles into an HTTP 500.