Skip to content

Android - Unable to send an MP3 file through the share menu #96933

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.4.44-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/66080924/folder/13176721/41236967/1597948954?sort=%2Bidentifier
Email or phone of affected tester (no customers): applausetester+tacj1@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Android
App Component: Other

Action Performed:

  1. Select an MP3 file from the device.
  2. Tap Share.
  3. Select the Expensify app.
  4. Try to send the MP3 file.

Expected Result:

The MP3 file should be sent successfully.

Actual Result:

The MP3 file is not sent.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome Safari

Screenshots/Videos

Bug7215982_1784856736301.WhatsApp_Video_2026-07-24_at_03.31.03.mp4

_Slack-_Boing-2026-06-16_23_21_29.195-2026-07-24 01_14_47.527.mp3

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7215982

Activity

  1. applause-bot commented on Jul 24, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/bc4ca38e816d20b4e56d8fab64960b19091e0d754e131fdfed23ec0c865098a2

  2. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 24, 2026
  3. melvin-bot commented on Jul 24, 2026

    @melvin-bot

    Triggered auto assignment to @Julesssss (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  4. melvin-bot commented on Jul 24, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  5. github-actions commented on Jul 24, 2026

    @github-actions
    Contributor

    👋 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:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  6. MelvinBot commented on Jul 24, 2026

    @MelvinBot
    Contributor

    🔍 Investigation Summary

    Classification: Frontend bug
    Causing PR: #95518 - "feat: Enable react-native-nitro-fetch (V3)" by @chrispader (High confidence)
    Related Issues: Previously reverted iterations of the same feature: #88110 (V1) and #94469 (V2, reverted via #95284 which is also on this deploy)

    Recommendation: REVERT

    This PR globally replaces the native fetch implementation with react-native-nitro-fetch (an HTTP/Cronet client), and the Share send path reads the local file via fetch(file://…) — a scheme NitroFetch does not handle like RN's default fetch — so the MP3 blob comes back empty on Android and the send silently no-ops. Reverting restores the working native fetch for local file reads; this feature has already been reverted twice (V1/V2), so a clean revert is the safest path while the file-URI handling is fixed.

    Assigned: @chrispader (PR author), @roryabraham and @mkhutornyi (approving reviewers)
    Labels: No label changes. DeployBlockerCash kept (an App PR caused the regression; App deploy remains blocked). No DeployBlocker (Web) label was present.

    📋 Detailed Analysis

    Evidence

    • The bug is Android-only and reproduces on staging v9.4.44-0 but not production — a regression introduced by a PR on this deploy.

    • Comparing production...staging, none of the Share pages (ShareRootPage.tsx, ShareDetailsPage.tsx, getFileSize), FileUtils.ts, addAttachmentWithComment, the native FileIntentHandler.kt/ShareActionHandlerModule.kt, or SHARE_FILE_MIMETYPE (which already lists audio/mpeg and audio/mp3) were changed. So the MIME gate and the send helpers themselves are not the regression.

    • I scanned every PR on the v9.4.44 StagingDeployCash checklist (Deploy Checklist: New Expensify 2026-07-23 #96914). The only one that alters the shared network/file-read path is feat: Enable react-native-nitro-fetch (V3) #95518, which adds src/polyfills/NitroFetch.ts and wires it as the first polyfill in index.js:

      // index.js — import of polyfills should always be first
      import './src/polyfills/NitroFetch';
      // src/polyfills/NitroFetch.ts
      globalThis.fetch = nitroFetch;
      globalThis.Headers = NitroHeaders;
      globalThis.Request = NitroRequest;
      globalThis.Response = NitroResponse;
    • The PR body explicitly states: "By globally replacing fetch, Headers, Request, and Response on native, existing fetch(...) callsites and dependencies keep the same API while routing through NitroFetch" and "the changes in this PR affect all network requests across the whole app." On web the vanilla fetch is retained — consistent with the bug being native/Android-only.

    • This exact feature has been shipped and reverted twice already (V1 feat: Enable react-native-nitro-fetch #88110, V2 feat: Enable react-native-nitro-fetch (V2) #94469 reverted by [CP Staging + Prod] Revert "feat: Enable react-native-nitro-fetch (V2)" #95284), indicating a history of regressions from the global fetch swap.

    Verification

    • Affected send path — ShareDetailsPage.handleShare → readFileAsync in src/libs/fileDownload/FileUtils.ts, which reads the local file blob via fetch:
      const readFileAsync: ReadFileAsync = (path, fileName, onSuccess, onFailure = () => {}, fileType = '') =>
          new Promise((resolve) => {
              if (!path) { resolve(); onFailure('[FileUtils] Path not specified'); return; }
              fetch(path)                       // path is a local file://  /  content:// URI
                  .then((res) => {
                      // fetch is "Unable to read uploaded file" on Android even though the blob is returned,
                      // so we'll ignore in that case
                      if (!res.ok && Platform.OS !== 'android') { throw Error(res.statusText); }
                      res.blob().then((blob) => {
                          const file = new File([blob], cleanFileName(fileName), {type: blob.type || fileType});
                          ...
      Note the code already tolerates non-OK responses on Android (line ignores !res.ok), so when NitroFetch cannot read the file:///content:// blob the flow proceeds with an empty/invalid blob, and the attachment upload produces nothing — matching the reported "tap Send → nothing sends."
    • Confirmed via gh pr view 95518 --json files that feat: Enable react-native-nitro-fetch (V3) #95518 adds src/polyfills/NitroFetch.ts, src/polyfills/NitroFetch.web.ts, the react-native-nitro-fetch patch, and modifies index.js, src/libs/HttpUtils.ts, src/libs/Request.ts, and the Android native networking files — i.e. it owns the global native fetch that readFileAsync depends on.
    • Merged 2026-07-23T19:14:35Z — squarely inside the v9.4.44 deploy window (2026-07-20 → 2026-07-24).

    Root Cause

    react-native-nitro-fetch is a native HTTP client (Cronet on Android). After #95518 replaces globalThis.fetch with it on native, any fetch() against a local file:// / content:// URI — as used by readFileAsync to load the shared MP3 into a Blob before upload — no longer returns the file's bytes the way RN's default fetch did. The resulting empty/invalid blob means the attachment is never actually uploaded, so tapping Send does nothing on Android. Web is unaffected because it keeps the browser's native fetch.

    Exact changed line that breaks MP3 sending (from #95518):
    src/polyfills/NitroFetch.ts:7 → globalThis.fetch = nitroFetch; (installed first via index.js: import './src/polyfills/NitroFetch';), which redirects the fetch(path) call in readFileAsync (src/libs/fileDownload/FileUtils.ts:265) away from the native file-URI-capable fetch.

  7. MelvinBot commented on Jul 24, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The Android share flow decides whether a shared file is "allowed" solely from the mime type the sending app declares in the intent — it never falls back to the file extension. So an MP3 shared by an app that declares a generic or non‑standard mime (e.g. application/octet-stream, audio/x-mpeg, or an empty type) is rejected before it can be sent, even though it is a valid .mp3.

    The chain:

    • The native handler stores the intent's mime verbatim: FileIntentHandler.kt:26 passes intent.type straight into ShareFileObject. The extension is only used to name the copied file (FileUtils.kt:100), never to derive the mime.
    • The JS gate then rejects anything whose mime isn't an exact string match in CONST.SHARE_FILE_MIMETYPE: ShareRootPage.tsx:108-112. On failure it shows the wrongFileType / notAllowedExtension alert and routes back to the Inbox — i.e. "the MP3 is not sent."

    audio/mpeg and audio/mp3 are in the allowlist (CONST/index.ts:2745-2750), so the failure only happens when the source app declares a mime that isn't one of those exact strings. Because the gate has no extension fallback, a correctly‑named .mp3 still gets blocked.

    Rest of the flow is fine — evidence

    The send path itself handles audio correctly, which is why the failure is at the gate and not later:

    • Preview: MP3 is not video/image/PDF, so AttachmentPreview.tsx:139 falls through to DefaultAttachmentView — no onLoadError, no spurious "corrupt attachment" alert.
    • readFileAsync already has an Android fallback to the caller‑supplied fileType and tolerates the Android fetch quirk: FileUtils.ts:270-277.
    • Size limits (24 MB max / 240 B min) are not the cause for a normal MP3: CONST/index.ts:347-355.

    Confidence: Medium. The mechanism and code path are confirmed by static analysis, but I could not confirm the exact mime string the tester's MP3 carried. Worth confirming: on the failing device, log tempFile.mimeType at ShareRootPage.tsx:108 (or intent.type in FileIntentHandler) — if it's anything other than audio/mpeg / audio/mp3, this is confirmed.

    What changes do you think we should make in order to solve the problem?

    Make the mime resolution extension‑aware so a valid .mp3 isn't blocked by a mislabeled or missing intent type:

    1. In the native handler, when intent.type is null/empty or generic (application/octet-stream/*/*), derive the mime from the file extension via MimeTypeMap.getMimeTypeFromExtension(...) before storing it (FileIntentHandler.kt / ShareActionHandlerModule.kt). MimeTypeMap is already imported in FileUtils.kt.
    2. As a JS safety net, when the incoming mime isn't in SHARE_FILE_MIMETYPE, fall back to mapping the file extension (already computed at ShareRootPage.tsx:140) to an allowed mime before showing the wrongFileType error.

    This keeps the change entirely within the App repo (native Android + JS) and preserves the existing allowlist as the source of truth.

    What alternative solutions did you explore? (Optional)

    If the confirmation step above shows the mime is actually audio/mpeg/audio/mp3 (already allowed) and the file still fails to upload after the gate, the failure would be on the HybridApp/backend send path rather than in App — that would need a separate internal investigation, since it's outside this repo.


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/96933) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.

  8. mkhutornyi commented on Jul 24, 2026

    @mkhutornyi
    Contributor

    I am not able to reproduce this locally

  9. Julesssss commented on Jul 24, 2026

    @Julesssss
    Contributor

    Reverting and requested CPs here

  10. Julesssss commented on Jul 24, 2026

    @Julesssss
    Contributor

    Requested QA here now that reverts hit staging

  11. m-natarajan commented on Jul 25, 2026

    @m-natarajan

    Unable to repro, Pixel 4/Android 13, v9.4.44-6

    az_recorder_20260724_211107.mp4
  12. yuwenmemon commented on Jul 25, 2026

    @yuwenmemon
    Contributor

    Thanks @m-natarajan !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.EngineeringHourlyKSv2ReviewingHas a PR in review

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions