You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Android/iOS - The image attachment is not cached on Android and iOS devices #85604
Version Number: v9.3.39-1 Reproducible in staging?: Yes Reproducible in production?: N/A - new feature, doesn't exist in prod If this was caught during regression testing, add the test name, ID and link from BrowserStack:#65321 Email or phone of affected tester (no customers): N/A Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: Android 13 / Xiaomi Poco F5, iOS 15.8.3 / iPhone 7 Plus App Component: Other
Action Performed:
Open the App
Go to any chat
Upload a single or multiple attachment files
On Android, go to root/android/data/org.me.mobiexpensifyg and try to find the cached image file
On iOS, go to On My iPhone/Expensify and try to find the cached image file
Expected Result:
The image attachment cache file can be found in the local folder of Android and iOS devices
Actual Result:
The image attachment is not cached on Android and iOS devices
Note:
On Android, the Expensify folder (root/android/data/org.me.mobiexpensifyg) exists, but there is no image cached file
On iOS, the Expensify folder (On My iPhone/Expensify) exists, but there is no image cached file
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
Identify the pull request that introduced this issue and revert it.
Classification: Frontend bug Causing PR: #65321 - "(1/2) Implement store/caching for attachments" by @NJ-2020 (High confidence) Related Issues: None
Recommendation: REVERT
The PR attempts to cache attachment files to a directory that is never created, causing all file caching operations to fail silently on native platforms.
Labels: Keeping DeployBlockerCash (blocks App deploy). This is a frontend bug in the App repository.
📋 Detailed Analysis
Evidence
The issue was introduced in PR #65321, which adds attachment caching functionality. The PR was merged on 2026-03-16 and is included in the current staging deploy (v9.3.39-1). The bug is only reproducible on staging (where the PR exists) and affects both Android and iOS native apps.
Verification
The PR modifies the attachment handling code and adds new files:
Line 10 defines: const ATTACHMENT_DIR = \${RNFS.DocumentDirectoryPath}/attachments`;`
Lines 22 and 56 attempt to write files to this directory:
Line 22: await RNFS.copyFile(uri, destPath); - Copies uploaded files
Line 56: await RNFetchBlob.config({path: filePath}).fetch('GET', uri); - Downloads remote files
Root Cause
The attachments directory is never created before attempting to save files to it.
When RNFS.copyFile() or RNFetchBlob.config({path}) try to write to a non-existent directory, the operations fail. The errors are caught and logged as warnings (lines 28 and 64), but the files are never actually cached.
This is different from the existing iOS file download implementation (src/libs/fileDownload/index.ios.ts line 69), which properly creates the directory first:
Please re-state the problem that we are trying to solve in this issue.
Image attachments uploaded in chat are not being cached on Android and iOS devices. After uploading a single or multiple attachment files, no cached image files can be found in the device's local storage.
What is the root cause of that problem?
The attachments subdirectory under RNFS.DocumentDirectoryPath is never created before the code attempts to write files to it.
But RNFS.mkdir(ATTACHMENT_DIR) is never called anywhere in the codebase. When cacheAttachment runs:
For local file uploads (line ~22): RNFS.copyFile(uri, destPath) throws because the destination directory doesn't exist
For remote URLs (line ~56): RNFetchBlob.config({path: filePath}).fetch('GET', uri) also fails for the same reason
Both failures are silently swallowed by catch blocks that only call Log.warn('[AttachmentCache] Failed to cache attachment', {error}). Since the Onyx.set() call is inside the try block after the failing write, the Onyx record is never created either — so the system has no record that caching was even attempted.
For comparison, the iOS file download code at src/libs/fileDownload/index.ios.ts:67-69 correctly calls RNFS.mkdir(expensifyDir) before writing files — the attachment caching code does not follow this pattern.
What changes do you think we should make in order to solve the problem?
Add await RNFS.mkdir(ATTACHMENT_DIR) at the top of the cacheAttachment function in src/libs/actions/Attachment/index.native.ts, before any file write operations. RNFS.mkdir() is a no-op if the directory already exists, so it's safe to call every time.
What alternative solutions did you explore? (Optional)
Create directory at app startup: Could add the mkdir call in platform setup, but lazy creation before each write is the pattern used elsewhere in the codebase (e.g., index.ios.ts) and is simpler.
Create directory once with a flag: Could track whether the directory was created with a module-level boolean, but RNFS.mkdir is already idempotent so this adds complexity with no benefit.
Note: PR #85588 "(2/2): Add preview caching logic" is currently open and will wire up getCachedAttachment for display. The write-side fix (this bug) should be addressed in the (1/2) PR scope since the cache files need to exist before (2/2) can read them.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.
This issue has not been updated in over 15 days. @Julesssss, @NJ-2020 eroding to Monthly issue.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
This issue has not been updated in over 15 days. @Julesssss, @NJ-2020 eroding to Monthly issue.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
Activity
melvin-bot commentedon Mar 17, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #65321
melvin-bot commentedon Mar 17, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon Mar 17, 2026
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
OSBotify commentedon Mar 17, 2026
🔍 Investigation Summary
Classification: Frontend bug
Causing PR: #65321 - "(1/2) Implement store/caching for attachments" by @NJ-2020 (High confidence)
Related Issues: None
Recommendation: REVERT
The PR attempts to cache attachment files to a directory that is never created, causing all file caching operations to fail silently on native platforms.
Labels: Keeping
DeployBlockerCash(blocks App deploy). This is a frontend bug in the App repository.📋 Detailed Analysis
Evidence
The issue was introduced in PR #65321, which adds attachment caching functionality. The PR was merged on 2026-03-16 and is included in the current staging deploy (v9.3.39-1). The bug is only reproducible on staging (where the PR exists) and affects both Android and iOS native apps.
Verification
The PR modifies the attachment handling code and adds new files:
src/libs/actions/Attachment/index.native.ts- Native attachment caching implementationsrc/libs/CacheAPI/index.native.ts- Cache API stub for nativeKey file affected:
src/libs/actions/Attachment/index.native.tsLine 10 defines:
const ATTACHMENT_DIR = \${RNFS.DocumentDirectoryPath}/attachments`;`Lines 22 and 56 attempt to write files to this directory:
await RNFS.copyFile(uri, destPath);- Copies uploaded filesawait RNFetchBlob.config({path: filePath}).fetch('GET', uri);- Downloads remote filesRoot Cause
The
attachmentsdirectory is never created before attempting to save files to it.When
RNFS.copyFile()orRNFetchBlob.config({path})try to write to a non-existent directory, the operations fail. The errors are caught and logged as warnings (lines 28 and 64), but the files are never actually cached.This is different from the existing iOS file download implementation (
src/libs/fileDownload/index.ios.tsline 69), which properly creates the directory first:The fix would require adding
RNFS.mkdir(ATTACHMENT_DIR, {intermediates: true})before attempting to write files, similar to the iOS download pattern.MelvinBot commentedon Mar 17, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
Image attachments uploaded in chat are not being cached on Android and iOS devices. After uploading a single or multiple attachment files, no cached image files can be found in the device's local storage.
What is the root cause of that problem?
The
attachmentssubdirectory underRNFS.DocumentDirectoryPathis never created before the code attempts to write files to it.In
src/libs/actions/Attachment/index.native.ts:10,ATTACHMENT_DIRis defined as:But
RNFS.mkdir(ATTACHMENT_DIR)is never called anywhere in the codebase. WhencacheAttachmentruns:RNFS.copyFile(uri, destPath)throws because the destination directory doesn't existRNFetchBlob.config({path: filePath}).fetch('GET', uri)also fails for the same reasonBoth failures are silently swallowed by
catchblocks that only callLog.warn('[AttachmentCache] Failed to cache attachment', {error}). Since theOnyx.set()call is inside thetryblock after the failing write, the Onyx record is never created either — so the system has no record that caching was even attempted.For comparison, the iOS file download code at
src/libs/fileDownload/index.ios.ts:67-69correctly callsRNFS.mkdir(expensifyDir)before writing files — the attachment caching code does not follow this pattern.What changes do you think we should make in order to solve the problem?
Add
await RNFS.mkdir(ATTACHMENT_DIR)at the top of thecacheAttachmentfunction insrc/libs/actions/Attachment/index.native.ts, before any file write operations.RNFS.mkdir()is a no-op if the directory already exists, so it's safe to call every time.What alternative solutions did you explore? (Optional)
mkdircall in platform setup, but lazy creation before each write is the pattern used elsewhere in the codebase (e.g.,index.ios.ts) and is simpler.RNFS.mkdiris already idempotent so this adds complexity with no benefit.Note: PR #85588 "(2/2): Add preview caching logic" is currently open and will wire up
getCachedAttachmentfor display. The write-side fix (this bug) should be addressed in the (1/2) PR scope since the cache files need to exist before (2/2) can read them.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.18 remaining items
NJ-2020 commentedon May 7, 2026
Not overdue
melvin-bot commentedon Jun 1, 2026
This issue has not been updated in over 15 days. @Julesssss, @NJ-2020 eroding to Monthly issue.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
melvin-bot commentedon Sep 7, 2026
This issue has not been updated in over 15 days. @Julesssss, @NJ-2020 eroding to Monthly issue.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
melvin-bot commentedon Nov 4, 2026
@Julesssss, @NJ-2020, this Monthly task hasn't been acted upon in 6 weeks; closing.
If you disagree, feel encouraged to reopen it -- but pick your least important issue to close instead.