Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 of 6 tasks
kbecciv opened this issue Sep 25, 2023 · 20 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@kbecciv
Copy link

kbecciv commented Sep 25, 2023

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
@kbecciv kbecciv added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 25, 2023
@melvin-bot melvin-bot bot 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 Sep 25, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

Job added to Upwork: https://www.upwork.com/jobs/~012ee95879b3ee9fee

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 25, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

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

@kbecciv
Copy link
Author

kbecciv commented Sep 25, 2023

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)}`,
 },

@s77rt
Copy link
Contributor

s77rt commented Sep 25, 2023

@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

@waterim
Copy link
Contributor

waterim commented Sep 25, 2023

Yes, I can handle this

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 25, 2023
@amyevans amyevans self-assigned this Sep 25, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

📣 @s77rt 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

📣 @esh-g 🎉 An offer has been automatically sent to your Upwork account for the Reporter role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@esh-g
Copy link
Contributor

esh-g commented Sep 26, 2023

@s77rt but that PR was more than 2 weeks old... Shouldn't this be out of the regression period?

@s77rt
Copy link
Contributor

s77rt commented Sep 26, 2023

@esh-g The PR was deployed to production just 3 days ago. This is still within the regression period.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 2, 2023
@melvin-bot melvin-bot bot changed the title [$500] Request Money - App crashes when invalid id entered in the url while requesting money [HOLD for payment 2023-10-09] [$500] Request Money - App crashes when invalid id entered in the url while requesting money Oct 2, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 2, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.75-12 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-10-09. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

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:

@s77rt
Copy link
Contributor

s77rt commented Oct 3, 2023

@sophiepintoraetz
Copy link
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)

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 Daily KSv2 labels Oct 9, 2023
@sonialiap
Copy link
Contributor

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

@melvin-bot melvin-bot bot removed the Overdue label Oct 12, 2023
@s77rt
Copy link
Contributor

s77rt commented Oct 12, 2023

@sonialiap Accepted! Thanks!

@sonialiap
Copy link
Contributor

Paid 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
No open projects
Development

No branches or pull requests

7 participants