fix: reject cache files truncated after stat - #21893
OskarEichler wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: dc8317f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe cache deserializer now rejects files that end before their reported size. A unit test simulates truncation and verifies the error and read count. A patch changeset records the fix. ChangesCache file integrity
Suggested reviewers: Merge Risk: ⚪ Minimal · up to Truncated cache files are now rejected promptly instead of potentially hanging the reader. The change is localized and merge-ready after normal checks and review; no actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (3 passed)
Full details: Title checkExplanation The title uses the valid Conventional Commit form
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21893 +/- ##
=======================================
Coverage 95.09% 95.09%
=======================================
Files 702 702
Lines 90702 90707 +5
Branches 27376 27378 +2
=======================================
+ Hits 86249 86255 +6
+ Misses 4453 4452 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will improve performance by ×2.1
Performance Changes
Tip Curious why performance improved? Comment Comparing |
Summary
If a cache file shrank after
stat, positional reads could repeatedly return zero bytes while the original size still indicated remaining data. The reader now treats zero bytes before the expected end as truncation and rejects instead of looping indefinitely.What kind of change does this PR introduce?
fix
Did you add tests for your changes?
Yes. A bounded fake filesystem simulates truncation after metadata lookup and verifies an EOF error after two reads. The focused unit suite passes 13 tests, and all lint, generated-output, type, format, spelling, changeset, and diff checks pass.
Does this PR introduce a breaking change?
No. Corrupt cache input now fails promptly instead of hanging.
If relevant, did you update the documentation?
A patch changeset documents truncated-cache rejection. No public documentation change is required.
Use of AI
Significant AI assistance was used to audit cache I/O and draft the fix and regression test. I reviewed the final diff and verification results.
Summary by CodeRabbit
Bug Fixes
Tests