fix(useFiles): stop warning on expected evicted-media reads#575
Open
Pasumarthi Rutwik (rutwik2001) wants to merge 1 commit into
Open
fix(useFiles): stop warning on expected evicted-media reads#575Pasumarthi Rutwik (rutwik2001) wants to merge 1 commit into
Pasumarthi Rutwik (rutwik2001) wants to merge 1 commit into
Conversation
readFile() logged a warn on every encrypted read that returned no local bytes, conflating two cases: (1) the file is simply not on this device (evicted off-device or synced as metadata but never pulled) and (2) a genuine decrypt/IO failure. Case (1) is an expected state once media eviction + backup restore is in play, so it spammed warn on each render of restorable media. Split the outcomes: a null result (clean not-found) now logs at debug and falls through to the legacy/restore path quietly; only a thrown error (decrypt/IO) keeps the warn. Behavior is unchanged — the caller still resolves missing bytes via backup-first restore (EvictedMediaTile / downloadEvictedMedia). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Dependency graphChanged files are highlighted in green. flowchart LR
subgraph 0["src"]
subgraph 1["react"]
2["index.ts"]
3["useFiles.ts"]
end
end
2-->3
2-->3
style 3 fill:lime,color:black
|
Contributor
Import Impact
Impact detailsstarter-next
ai-memoryless-client
Changed SDK files (1)
|
Contributor
Coverage Report
File CoverageNo changed files found. |
Contributor
Integration Check ✅ (baseline matches)Failures also occur on
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
readFile()logged awarnfor every encrypted read that returned no local bytes, conflating two distinct cases: the file simply isn't on this device (evicted off-device, or synced as metadata but never pulled) vs. a genuine decrypt/IO failure.[useFiles] Encrypted read failed ... trying legacy storageon each render of restorable media.nullresult (clean not-found) now logs atdebugand falls through quietly; only a thrown error (decrypt/IO) keeps thewarn.EvictedMediaTile/downloadEvictedMedia).Integration
None required. Console noise drops automatically. Apps that route the SDK
debuglevel to a no-op logger will see the evicted-read line disappear entirely; real decrypt/IO failures still surface atwarn.Breaking Changes
None.
Test plan
pnpm typecheck— cleanpnpm exec eslint src/react/useFiles.ts— cleanpnpm vitest runstorage/opfs suites — 48 passedwarnspam, EvictedMediaTile/tap-to-download still restoresNote
Low Risk
Logging-only refinement in encrypted read handling; file resolution and error throwing after legacy fallback are unchanged.
Overview
readFileinuseFilesnow treats anullfromreadEncryptedFile(no local encrypted bytes—evicted or metadata-only) as an expected path: it logs atdebugand continues to legacy OPFS instead of throwing and hitting thewarnpath labeled “encrypted read failed.”Real decrypt/IO failures still
warnand fall back the same way. Restore/backup behavior is unchanged—callers still resolve missing bytes via evicted-media restore after legacy lookup fails.Reviewed by Cursor Bugbot for commit 7cab74d. Bugbot is set up for automated code reviews on this repo. Configure here.
Greptile Summary
Splits the log-level handling inside
readFile's encrypted path inuseFiles.tsto distinguish a clean "no local bytes" result (null) from a hard decrypt/IO failure (thrown error). Thenullbranch now logs atdebugand falls through to legacy OPFS storage quietly; thecatchbranch keeps itswarn.File could not be foundif also absent there."Encrypted read failed"was misleading for the eviction case — the newdebugmessage"No local encrypted bytes … (likely evicted)"is more precise.Confidence Score: 5/5
Safe to merge — the change only adjusts log verbosity and does not alter how callers receive file data.
The encrypted-read path's null/throw split is correctly handled: the null branch falls through to legacy storage the same way the old throw→catch path did, so no user-visible behavior changes. The warn message for real failures is preserved, and the new debug message is accurate. The single-file diff is minimal and easy to reason about end-to-end.
No files require special attention.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[readFile called] --> B{hasEncryptionKey?} B -- No --> F B -- Yes --> C[readEncryptedFile] C -- result is non-null --> D[return File] C -- result === null\nnot found / evicted --> E[log.debug\n'No local encrypted bytes'\nfall through] C -- throws\ndecrypt / IO error --> G[log.warn\n'Encrypted read failed'\nfall through] E --> F[Try legacy OPFS] G --> F F -- success --> H[return File from OPFS] F -- not found --> I[throw 'File could not be found']Reviews (1): Last reviewed commit: "fix(useFiles): stop warning on expected ..." | Re-trigger Greptile