Repository navigation
refactor(cache): standardize not-found checks - #1287
Conversation
|
This change is part of the following stack: Change managed by git-spice. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughStandardizes "not found" error classification in the cache package by replacing all ChangesCache not-found standardization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Code Review
This pull request standardizes "not found" error detection in the cache layer (pkg/cache) by replacing direct calls to ent.IsNotFound(err) with the single predicate database.IsNotFoundError(err). This ensures that both Ent's *NotFoundError and the package-level database.ErrNotFound sentinel are correctly recognized as not-found errors across all cache operations. The change includes adding the pkg/database import to pkg/cache/build_trace.go and updating the design documentation and specifications to reflect this requirement. There are no review comments, so I have no feedback to provide.
895160e to
106d5e9
Compare
8a4b3eb to
d887e91
Compare
106d5e9 to
014e8e3
Compare
The cache layer detected missing rows inconsistently: pkg/cache called ent.IsNotFound directly at ~20 sites while the purpose-built database.IsNotFoundError helper was used only once. The helper is the intended single predicate — it matches both Ent's *NotFoundError and the database.ErrNotFound sentinel returned by the cache test fakes. Calling ent.IsNotFound directly meant those sites silently failed to recognize the sentinel, and the not-found policy was scattered. Replace every direct ent.IsNotFound(x) in cache.go and build_trace.go with database.IsNotFoundError(x), preserving each argument and negation, and add the pkg/database import to build_trace.go. This is behavior-preserving for real Ent errors (the helper is a superset matcher) and strictly more correct for the sentinel, which the cache paths now honor — making the dual-mode predicate load-bearing rather than vestigial. Package-specific sentinels (storage/upstream/chunk/ config ErrNotFound) are left matched by their own errors.Is checks. Records a database-orm spec requirement for the single-predicate contract. Co-Authored-By: Claude Opus 4.8 <[email protected]>
014e8e3 to
0230e29
Compare
Summary
The cache layer detected missing rows inconsistently:
pkg/cachecalledent.IsNotFounddirectly at ~20 sites while the purpose-builtdatabase.IsNotFoundErrorhelper was used only once. That helper is the intended single predicate — it matches both Ent's*NotFoundErrorand thedatabase.ErrNotFoundsentinel returned by the cache test fakes. Callingent.IsNotFounddirectly meant those sites silently failed to recognize the sentinel.ent.IsNotFound(x)incache.goandbuild_trace.gowithdatabase.IsNotFoundError(x), preserving each argument and negation; add thepkg/databaseimport tobuild_trace.go.storage/upstream/chunk/configErrNotFound) are left matched by their ownerrors.Ischecks.database-ormspec requirement for the single-predicate contract.Test plan
task fmt/task lint(0 issues) /task test(full suite green)database.ErrNotFound) covers the not-found paths