Skip to content

[HOLD for payment 2023-10-09] [$500] Request Money - App crashes when invalid id entered in the url while requesting money #28182

Closed

Description

@kbecciv

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


Action Performed:

  1. Click on FAB > Request Money
  2. Enter any amount.
  3. Select any participant.
  4. Edit the url and change the id number to something invalid.

Expected Result:

The app should show the not found page

Actual Result:

App crashes

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.74.0
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation

Screen.Recording.2023-09-23.at.9.40.25.PM.mov
Recording.4765.mp4

Expensify/Expensify Issue URL:
Issue reported by: @esh-g
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1695485570103699

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~012ee95879b3ee9fee
  • Upwork Job ID: 1706367444027846656
  • Last Price Increase: 2023-09-25
  • Automatic offers:
    • s77rt | Reviewer | 26873478
    • esh-g | Reporter | 26873479

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 25, 2023
  2. changed the title [-]Request Money - App crashes when invalid id entered in the url while requesting money[/-] [+][$500] Request Money - App crashes when invalid id entered in the url while requesting money[/+] on Sep 25, 2023
  3. melvin-bot commented on Sep 25, 2023

    @melvin-bot

    Triggered auto assignment to @sophiepintoraetz (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

  4. melvin-bot commented on Sep 25, 2023

    @melvin-bot
  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Sep 25, 2023
  6. melvin-bot commented on Sep 25, 2023

    @melvin-bot

    Bug0 Triage Checklist (Main S/O)

    • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
    • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
      • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
    • This bug is reproducible using the reproduction steps in the OP. S/O
      • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
      • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
    • This issue is filled out as thoroughly and clearly as possible
      • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
    • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync
  7. melvin-bot commented on Sep 25, 2023

    @melvin-bot

    Triggered auto assignment to @sonialiap (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

  8. melvin-bot commented on Sep 25, 2023

    @melvin-bot

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

  9. kbecciv commented on Sep 25, 2023

    @kbecciv
    Author

    Proposal by: @esh-g
    Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1695485570103699

    Proposal

    Please re-state the issue

    App crashes when invalid id entered in the url while requesting money

    What is the root cause of the problem?

    We actually have logic in the MoneyRequestConfirmPage to reset the IOU in case there is a mismatch between the current iou.id and the reportID here:

    // Reset the money request Onyx if the ID in Onyx does not match the ID from params
    const moneyRequestId = `${iouType.current}${reportID.current}`;
    const shouldReset = !isDistanceRequest && props.iou.id !== moneyRequestId;
    if (shouldReset) {
    IOU.resetMoneyRequestInfo(moneyRequestId);
    }

    But this crash is occurring before the above code is getting executed. Here is where the error is occurring:

    withOnyx({
    policy: {
    key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`,
    },
    }),

    We are trying to get the report.policyID but when the reportID is invalid, it returns the report as undefined so we are trying to access a property on undefined which is causing the error.

    What changes do you think should be made to fix this problem?

    Option 1
    We have started to allow optional chaining in the codebase, so we can use report?.policyID to prevent this error.

    policy: {
         key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`,
     },

    Option 2
    We can copy the approach how we handle this from the EditRequestPage.js file:

    policy: {
    key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`,
    },

    What other alternative options did you explore? (Optional)

    Option 3
    We can use the typical lodashGet(report, 'policyID', CONST.POLICY.OWNER_EMAIL_FAKE) here instead as well, if we don't want to use optional chaining.

    policy: {
         key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${lodashGet(report, 'policyID', CONST.POLICY.OWNER_EMAIL_FAKE)}`,
     },
  10. s77rt commented on Sep 25, 2023

    @s77rt
    Member

    @esh-g Thanks for the proposal. Your RCA is correct and the solutions makes sense. Given this is a regression from #27172 I think the C/C+ may handle this. cc @waterim @0xmiroslav

  11. 19 remaining items

  12. melvin-bot commented on Oct 2, 2023

    @melvin-bot

    BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

    • [@s77rt] The PR that introduced the bug has been identified. Link to the PR:
    • [@s77rt] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
    • [@s77rt] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
    • [@s77rt] Determine if we should create a regression test for this bug.
    • [@s77rt] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
    • [@sonialiap / @sophiepintoraetz] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  13. s77rt commented on Oct 3, 2023

    @s77rt
    Member
  14. sophiepintoraetz commented on Oct 5, 2023

    @sophiepintoraetz
    Contributor

    Hi @sonialiap! Looks like this was a fortuitous double-assignment - I'm headed OOO till 17 Oct so all that needs doing here is:

    1. @s77rt requires payment offer (Reviewer) and is eligible for the urgency bonus ($750)

    (I have paid the reporter already)

  15. sonialiap commented on Oct 12, 2023

    @sonialiap
    Contributor

    The offer link is not working for me so I've sent a new one - https://www.upwork.com/nx/wm/offer/27157108

  16. s77rt commented on Oct 12, 2023

    @s77rt
    Member

    @sonialiap Accepted! Thanks!

  17. sonialiap commented on Oct 13, 2023

    @sonialiap
    Contributor

    Paid 🎉

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions