Skip to content

[$175] "Report not found" screens and other receipt errors never reach Sentry #106965

Open

Description

@mountiny

Part of #106153 (receipt retention). Found by @adhorodyski.

Problem

  • The app logs the "report not found" screen, but that log is not on the list of logs sent to Sentry.
  • The app does not log loading placeholders that never finish.
  • The app does not log failed crops.

Impact

  • Severity: P1
  • About 4,000 to 5,000 "report not found" screens a day (Nov 10 to Nov 12). None of them are in Sentry.

Code

Related pull requests

Expected behavior

"Report not found" screens reach Sentry. Stuck placeholders and failed crops are logged.

Issue OwnerCurrent Issue Owner: @adhorodyski
Upwork Automation - Do Not Edit

Activity

  1. added
    Daily
    Bug
    on Nov 16, 2026
  2. added
    External
    on Nov 16, 2026
  3. expensify-chore-bot commented on Nov 16, 2026

    @expensify-chore-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @nyomanjyotisa (External)

  4. changed the title [-]"Report not found" screens and other receipt errors never reach Sentry[/-] [+][$175] "Report not found" screens and other receipt errors never reach Sentry[/+] on Nov 16, 2026
  5. expensify-chore-bot commented on Nov 16, 2026

    @expensify-chore-bot
  6. MelvinBot commented on Nov 16, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    Three separate telemetry gaps exist in App:

    1. “Report not found” already logs, but Sentry rejects the message. Its message does not match the forwarding allowlist. Adding the message alone would still discard its diagnostic parameters unless those are explicitly allowed.
    2. Image-loading timeouts update the UI without logging the timeout. Generic long-spinner warnings exist, so “placeholders never log” is too broad.
    3. Several receipt-crop failure paths silently return or fall back to the original image. Other crop paths already warn, but those warnings are not explicitly forwarded to Sentry.

    Confidence: medium overall. The code establishes these gaps, but production log access was unavailable. The reported 4,000–5,000 daily occurrences remain unverified. This analysis does not establish the cause of missing receipts or erased descriptions.

    Code evidence and alternative explanations checked

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

    • Allow the specific [ReportScreen] Displaying NotFound Page message family, covering both guards. Add narrowly scoped, privacy-reviewed diagnostic fields.
    • Log at the existing image-timeout transition, with component and timeout reason. Preserve offline behavior, retries and late-success recovery; do not introduce another timer.
    • Add fixed failure events for receipt-crop rejection, missing output and fallback paths. Distinguish manipulation failure from downstream save failure. Cover automatic cropping and web camera cropping separately; receipt-editor catches do not cover those paths.
    • Forward the new events with explicitly allowed metadata. Exclude receipt URLs, local paths, filenames, image data and unsanitized error messages.
    • Preserve expected invalid/deleted-report behavior. These should reach Sentry Logs and breadcrumbs, not automatically become error issues.
    Regression coverage

    Test both not-found messages and metadata filtering; timeout logging once per attempt, with no event after success/offline/unmount; retry and late-success behavior; crop rejection, missing output and successful-original fallback. Assert unchanged UI cleanup and no sensitive data in messages or attributes.

    No runtime tests were executed.

    What alternative solutions did you explore? (Optional)

    Broadly forwarding all report/image warnings or changing every event to error severity would increase noise and risk exposing URL-bearing messages. Narrow event forwarding addresses the demonstrated gaps.

    Related issue: Error and loading states should log what happened and match what the user did overlaps with the broader state-logging work; coordinate coverage to avoid duplicate instrumentation.


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


    view run

  7. kevinjosh10 commented on Nov 16, 2026

    @kevinjosh10

    Proposal

    What is the root cause of that problem?

    There are three specific logging/telemetry gaps causing receipt errors and "Report not found" screens to be lost:

    1. [ReportScreen] Displaying NotFound Page is omitted from Sentry forwarder:
      In src/pages/inbox/ReportNotFoundGuard.tsx:89, the app logs when the not-found page is triggered:
    Log.info('[ReportScreen] Displaying NotFound Page', false, { ... });

    However, in src/libs/telemetry/forwardLogsToSentry.ts:35–44, FORWARDED_LOG_PREFIXES only contains:
    ['[MFA]', '[OnyxUpdateManagerError]', '[Receipt]', '[PDFStall]', '[OpenReportStall]', '[withNavigationFallback]', '[createDynamicRoute]', '[UpdateRequired]'].
    Because '[ReportScreen]' is missing from FORWARDED_LOG_PREFIXES and its parameters are not listed in PREFIX_SCOPED_PARAMETERS_WHITELIST, the Sentry logger silently filters out all 4,000–5,000 daily occurrences before they can be forwarded.

    1. Image loading timeout / placeholder stalls are unlogged:
      When a receipt fails to load and the stall timer fires in src/hooks/useImageLoadStall.ts / src/components/ImageWithLoading.tsx (introduced in PR Fail a receipt image that never loads instead of spinning forever #102887), the callback sets error/fallback states to dismiss the spinner, but never invokes Log.alert or Log.info with a [Receipt] prefix to record the timeout.

    2. Failed crops fail silently without error logging:
      In src/pages/iou/request/step/IOURequestStepScan/cropImageToAspectRatio.ts:56–80, src/pages/media/AttachmentModalScreen/routes/TransactionReceiptModalContent.tsx:456–504, and CameraCapture.tsx:44–92, when cropping fails (e.g. ImageManipulator.manipulateAsync throws or yields an invalid result), the catch block silently swallows the failure or falls back to the original image without logging any telemetry event.

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

    1. Forward [ReportScreen] not-found events to Sentry:
    • In src/libs/telemetry/forwardLogsToSentry.ts:
      • Add '[ReportScreen]' to FORWARDED_LOG_PREFIXES.
      • Add an entry for '[ReportScreen]' to PREFIX_SCOPED_PARAMETERS_WHITELIST allowing safe diagnostic keys:
        ['reportID', 'reportIDFromPath', 'isLoadingApp', 'isLoadingReportData', 'isOffline', 'isLoadingInitialReportActions', 'isOptimisticDelete', 'userLeavingStatus', 'isPendingCreation', 'deleteTransactionNavigateBackUrl', 'isBillHidden'].
    1. Log receipt loading placeholder stalls:
    • In src/hooks/useImageLoadStall.ts (or MoneyRequestReceiptView.tsx), when the image load stall timeout triggers:
      • Call Log.alert(${RECEIPT_LOG_PREFIX} loadingStalled, { event: 'loadingStalled', receiptTraceId, transactionID, timeoutMs, isOffline: String(getIsOffline()) }).
      • Ensure 'loadingStalled' and 'timeoutMs' are allowed under '[Receipt]' in PREFIX_SCOPED_PARAMETERS_WHITELIST.
    1. Log failed crop operations:
    • In src/pages/iou/request/step/IOURequestStepScan/cropImageToAspectRatio.ts and TransactionReceiptModalContent.tsx:
      • In the catch blocks where cropping fails or falls back to the original uncropped asset, call Log.alert(${RECEIPT_LOG_PREFIX} cropFailed, { event: 'cropFailed', receiptTraceId, transactionID, error: error?.message, fallbackToOriginal: true }).
      • Allow 'cropFailed' and 'fallbackToOriginal' in PREFIX_SCOPED_PARAMETERS_WHITELIST.

    What alternative solutions did you explore? (Optional)

    • We evaluated forwarding all general informational logs (Log.info) directly to Sentry. However, forwarding without prefix and parameter allowlists would flood Sentry with excessive log volume and potentially expose unredacted parameters. Scoping specifically to '[ReportScreen]' and instrumenting the missing failure branches under the existing '[Receipt]' umbrella maintains privacy and keeps error tracking clean.

    Contributor Details:

  8. cocvn157 commented on Nov 16, 2026

    @cocvn157

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    1. When users hit a "Report not found" screen (ReportNotFoundGuard), the app logs [ReportScreen] Displaying NotFound Page, but those logs are never forwarded to Sentry (0 of the ~4,000–5,000 daily occurrences reach Sentry).
    2. When receipt/image loading placeholders stall and never finish (useImageLoadStall in ImageView, ImageWithLoading, and Lightbox added in Fail a receipt image that never loads instead of spinning forever #102887, or long-running ActivityIndicator), the stall/timeout is not logged to Sentry.
    3. When cropping or rotating a receipt image fails (cropImageToAspectRatio.ts and TransactionReceiptModalContent.tsx), the .catch blocks silently swallow the error without logging.

    What is the root cause of that problem?

    1. [ReportScreen] is missing from FORWARDED_LOG_PREFIXES (src/libs/telemetry/forwardLogsToSentry.ts:242-251):

      • src/pages/inbox/ReportNotFoundGuard.tsx logs:
        • Line 95: Log.info('[ReportScreen] Displaying NotFound Page', false, { isLoadingApp, isLoadingReportData, isOffline, isLoadingInitialReportActions, reportID, isOptimisticDelete, userLeavingStatus, reportIDFromPath: routeParams?.reportID, isPendingCreation, deleteTransactionNavigateBackUrl, isBillHidden });
        • Line 181: Log.info('[ReportScreen] Displaying NotFound Page (deleted transaction thread)', false, { reportIDFromPath, isParentActionDeleted, isParentActionMissingAfterLoad });
      • However, FORWARDED_LOG_PREFIXES in src/libs/telemetry/forwardLogsToSentry.ts does not include '[ReportScreen]', and PREFIX_SCOPED_PARAMETERS_WHITELIST does not whitelist its parameter keys, so getMatchedForwardPrefix returns undefined and drops every [ReportScreen] log.
    2. Stalled image/receipt loading placeholders do not emit a forwarded log when useImageLoadStall times out:

      • In PR Fail a receipt image that never loads instead of spinning forever #102887 (src/hooks/useImageLoadStall.ts, src/components/ImageView/index.tsx:95-98, src/components/ImageWithLoading.tsx:75-78, and src/components/Lightbox/index.tsx:230-233), handleLoadTimeout sets updateLoadTimedOut(true) and setIsLoading(false), and ActivityIndicator logs [AppState] Will log app state on long loading..., neither of which emits a [Receipt] (or forwarded [ImageLoadStall]) log to Sentry.
    3. Failed receipt crops and rotations swallow errors in .catch without logging:

      • In src/pages/iou/request/step/IOURequestStepScan/cropImageToAspectRatio.ts:80, the promise chain ends with .catch(() => image) without logging the failure.
      • In src/pages/media/AttachmentModalScreen/routes/TransactionReceiptModalContent.tsx, both rotateReceipt (line 434: .catch(() => { setIsRotating(false); })) and saveCrop (line 508: .catch(() => { setIsCropSaving(false); exitCropMode(); })) swallow errors from cropOrRotateImage / applyDurableReceipt without logging.

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

    1. Forward [ReportScreen] NotFound logs and their safe diagnostic parameters to Sentry (src/libs/telemetry/forwardLogsToSentry.ts & src/pages/inbox/ReportNotFoundGuard.tsx):

      • Use Log.warn (or keep Log.info and include '[ReportScreen]' in FORWARDED_LOG_PREFIXES) in ReportNotFoundGuard.tsx:95 and 181.
      • In src/libs/telemetry/forwardLogsToSentry.ts:
        • Add '[ReportScreen]' to FORWARDED_LOG_PREFIXES.
        • Add a ['[ReportScreen]', ['isLoadingApp', 'isLoadingReportData', 'isOffline', 'isLoadingInitialReportActions', 'reportID', 'isOptimisticDelete', 'userLeavingStatus', 'reportIDFromPath', 'isPendingCreation', 'deleteTransactionNavigateBackUrl', 'isBillHidden', 'isParentActionDeleted', 'isParentActionMissingAfterLoad']] entry to PREFIX_SCOPED_PARAMETERS_WHITELIST.
    2. Log stalled image/receipt loading placeholders to Sentry (src/components/ImageView/index.tsx, src/components/ImageWithLoading.tsx, src/components/Lightbox/index.tsx, or src/hooks/useImageLoadStall.ts):

      • When useImageLoadStall triggers onStalled (or inside handleLoadTimeout in ImageView, ImageWithLoading, and Lightbox, / ReceiptImage placeholder timeouts), emit a forwarded warning log (e.g. Log.warn('[Receipt] Image load stalled', { event: 'image_load_stalled', context, hasActivity, hasPreview }) or under a dedicated '[ImageLoadStall]' prefix in FORWARDED_LOG_PREFIXES with ['context', 'hasActivity', 'hasPreview', 'attachmentID', 'isLocalFile'] whitelisted, never logging raw URLs/filenames).
    3. Log failed receipt crops and rotations (src/pages/iou/request/step/IOURequestStepScan/cropImageToAspectRatio.ts & src/pages/media/AttachmentModalScreen/routes/TransactionReceiptModalContent.tsx):

      • In src/pages/iou/request/step/IOURequestStepScan/cropImageToAspectRatio.ts:80:
        .catch((error: unknown) => {
            Log.warn('[Receipt] Failed to crop image to aspect ratio', {
                event: 'crop_failed',
                errorMessage: error instanceof Error ? error.message : String(error),
            });
            return image;
        });
      • In src/pages/media/AttachmentModalScreen/routes/TransactionReceiptModalContent.tsx (rotateReceipt and saveCrop .catch blocks), log Log.warn('[Receipt] Failed to crop or rotate receipt', { event: 'crop_or_rotate_failed', transactionID: transaction.transactionID, errorMessage: error instanceof Error ? error.message : String(error) }) so all failed crops/rotations are forwarded under [Receipt] to Sentry.
    4. Add unit tests (tests/unit/forwardLogsToSentryTest.ts, tests/unit/calculateCropRectTest.ts, tests/unit/hooks/useImageLoadStall.test.ts):

      • Verify [ReportScreen] logs and their whitelisted parameters are forwarded to Sentry.logger and Sentry.addBreadcrumb.
      • Verify stalled image loads and failed cropImageToAspectRatio calls emit forwarded Sentry logs without leaking raw file URIs or filenames.

    What alternative solutions did you explore? (Optional)

    • Widening the global PARAMETERS_WHITELIST instead of using PREFIX_SCOPED_PARAMETERS_WHITELIST: Using PREFIX_SCOPED_PARAMETERS_WHITELIST for '[ReportScreen]' and '[Receipt]' follows the existing pattern in forwardLogsToSentry.ts so diagnostic keys are strictly scoped to their prefix and cannot leak from unrelated logs.
  9. dankezo commented on Nov 16, 2026

    @dankezo

    Contributor details
    Your Expensify account email: dannyphan190@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~013b564a690d9bcdab

    Proposal

    Problem

    "Report not found" screens never reach Sentry, and several receipt errors
    are never logged at all - so the team cannot see how often users hit a dead
    end, or why receipt rotate/crop operations fail.

    Root cause

    Sentry forwarding is allowlist-based, and the report-screen logs are not on
    the list:

    • forwardLogsToSentry only forwards a log line when its message contains
      one of FORWARDED_LOG_PREFIXES (src/libs/telemetry/forwardLogsToSentry.ts:35-44):
      [MFA], [OnyxUpdateManagerError], [Receipt], [PDFStall],
      [OpenReportStall], [withNavigationFallback], [createDynamicRoute],
      [UpdateRequired]. [ReportScreen] is not among them.
    • ReportNotFoundGuard (src/pages/inbox/ReportNotFoundGuard.tsx) logs
      both not-found cases with exactly that prefix - "Displaying NotFound Page"
      (lines 89-100) and "Displaying NotFound Page (deleted transaction thread)"
      (lines 175-179) - so both are dropped before Sentry ever sees them.

    The log LEVEL is not the blocker, and it is worth stating why:
    mapLogMessageToSentryLevel (forwardLogsToSentry.ts:98-109) forwards every
    level - [alrt] as error, [warn]/[hmmm] as warn, [info] as info,
    anything else as debug. Once the prefix is allowlisted, the existing lines
    forward as-is. Any fix that only changes levels, or only adds logging calls,
    does nothing.

    Separately, two receipt errors are never logged in the first place: in
    TransactionReceiptModalContent, the rotate flow's catch (lines 429-431)
    and the crop-save flow's catch (lines 501-503) swallow the error with only a
    state reset (setIsRotating(false) / setIsCropSaving(false)). No log line
    exists for the prefix filter to forward.

    Changes

    1. Allowlist the prefix. Add '[ReportScreen]' to
      FORWARDED_LOG_PREFIXES in forwardLogsToSentry.ts.

    2. Scope its parameters. Add a '[ReportScreen]' entry to
      PREFIX_SCOPED_PARAMETERS_WHITELIST for the parameters the two guard
      logs actually carry (reportIDFromPath and the loading/offline flags),
      mirroring the [PDFStall] / [OpenReportStall] entries that whitelist
      reportID. Nothing else about these lines is forwarded - the whitelist
      discipline the file's own warning comment demands is preserved.

    3. Raise the two guard logs to the right level. Change both
      ReportNotFoundGuard logs from Log.info to Log.warn. A report the
      user navigated to cannot be shown - that is a user-facing dead end and
      belongs at Sentry warn level, visible but not an error storm. NOT
      Log.alert: at thousands of not-found displays a day, error level would
      flood Sentry and drown real errors - the same reason receipt
      observability reserves alert for drops and give-ups.

    4. Log the swallowed receipt errors. In TransactionReceiptModalContent,
      the rotate and crop-save catches log the caught error with Log.warn
      under the existing [Receipt] prefix (already allowlisted, with its
      scoped parameter whitelist) before resetting the state flags. The user
      experience is unchanged; the failure becomes visible.

    Not changed: the not-found UI itself, the guard's conditions for showing
    it, any other prefix or whitelist entry, and the forwarding of levels -
    mapLogMessageToSentryLevel already does the right thing.

    Tests

    • tests/unit/forwardLogsToSentryTest.ts (exists): a [ReportScreen]
      Log.warn line is forwarded at warn level with its whitelisted parameters,
      a non-whitelisted parameter on the same line is stripped, and a
      [ReportScreen] line is no longer dropped.
    • ReportNotFoundGuard rendering is unchanged (the guard still shows the
      not-found page under the same conditions) - covered by its existing tests.
    • The rotate/crop catches still reset their state flags when the underlying
      call rejects, now with the warn log emitted.

    Alternatives considered

    • Use Log.alert for the not-found logs (as in one existing proposal).
      Rejected: alert maps to Sentry error level. These events are frequent and
      usually not actionable one by one; warn preserves the signal (counts,
      parameters, trends) without flooding the error stream.
    • Change mapLogMessageToSentryLevel or forward all prefixes.
      Rejected: the level mapping already forwards everything, and the prefix
      allowlist is a deliberate privacy control (the file warns there is no
      redaction yet). The fix works within that control instead of weakening it.
    • Add new log calls in the guard instead of allowlisting the prefix.
      Rejected: the log calls already exist with the right parameters; the
      filter is what drops them.
  10. melvin-bot commented on Nov 16, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  11. 7 remaining items

  12. oqildev commented on Nov 23, 2026

    @oqildev
    Contributor

    @adhorodyski I looked into this one. Two of the three parts are already in open PRs: #107120 logs the not-found screen in both guards, and #107399 logs the image stalls from useImageLoadStall. If MelvinBot's proposal goes in as written, each not-found screen and each stall would reach Sentry twice, and the PRs would conflict.

    Nothing covers the failed crops yet. I found four places where a crop fails without a log: rotate and crop in the receipt editor, the iOS fallback in cropOrRotateImage (it saves the uncropped image and only logs an unprefixed warn), cropImageToAspectRatio for odometer photos, and the web camera, where the shutter blinks but no photo is taken. I checked each one in the code, and confirmed the iOS warn and cropImageToAspectRatio cases with a quick test on main.

    I think this issue should only cover the crops. I can log them with [Receipt] keys that are already allowed, so it won't conflict with either PR. Should I post a proposal?

  13. expensify-chore-bot commented on Nov 23, 2026

    @expensify-chore-bot

    @adhorodyski Still overdue 6 days?! Let's take care of this!

  14. expensify-chore-bot commented on Nov 25, 2026

    @expensify-chore-bot

    @adhorodyski 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

  15. expensify-chore-bot commented on Nov 27, 2026

    @expensify-chore-bot

    @adhorodyski 10 days overdue. I'm getting more depressed than Marvin.

  16. added
    Weekly
    and removed
    Daily
    on Nov 28, 2026
  17. mountiny commented on Nov 28, 2026

    @mountiny
    ContributorAuthor

    @rinej is this something you could look into?

  18. rinej commented on Nov 30, 2026

    @rinej
    Contributor

    yes, I will wrap up my current work and jump into it

  19. expensify-chore-bot commented on Nov 30, 2026

    @expensify-chore-bot

    @mountiny @adhorodyski @nyomanjyotisa this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

  20. rinej commented on Dec 1, 2026

    @rinej
    Contributor

    I checked the problems from the description. Some of the PRs on this topic were already merged (mostly in #107399 and #107120). So part of it is covered and logs are already showing up in Sentry at least on staging.

    What is left:

    • Logging for the expense report opened from Search
    • Few receipt crops errors still fail without a log

    I am working on the PR for them

  21. added
    Reviewing
    on Dec 3, 2026
  22. rinej commented on Dec 3, 2026

    @rinej
    Contributor

    I split this into two PRs:

    • Report not found screens never reach Sentry #108707 sends the "not found" page you get when opening an expense report from Search to Sentry. It's straightforward to test - open a Search link to a report that doesn't exist and check the line in Sentry

    • Receipt crop never reach Sentry #108784 logs receipt crops that fail without telling anyone. This one would be trickier to test, because the failures have to be forced with a small local patch. The steps are in the PR

    Please have a look!

  23. mountiny commented on Dec 3, 2026

    @mountiny
    ContributorAuthor

    @rinej thank! There are some codex comments to address on one of them

  24. rinej commented on Dec 4, 2026

    @rinej
    Contributor

    done, addressed on the comments

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

Metadata

Metadata

Labels

BugExternalReviewingWeekly

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions