-
Notifications
You must be signed in to change notification settings - Fork 3k
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 2024-06-20] [HOLD for payment 2024-06-18] [$500] [CRITICAL] [UX Reliability] App Crash with Invalid Currency code #43004
Comments
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ahmedGaber93 ( |
Triggered auto assignment to @CortneyOfstad ( |
Looking for proposals |
|
Job added to Upwork: https://www.upwork.com/jobs/~01365ad3a139cd53cd |
Current assignee @ahmedGaber93 is eligible for the External assigner, not assigning anyone new. |
ProposalPlease re-state the problem that we are trying to solve in this issue.App Crash with Invalid Currency code What is the root cause of that problem?When the Lines 100 to 110 in a015db7
What changes do you think we should make in order to solve the problem?If What alternative solutions did you explore? (Optional)We can use We can pass Lines 146 to 152 in a015db7
|
ProposalPlease re-state the problem that we are trying to solve in this issue.Non supported currency turns error What is the root cause of that problem?We are passing an empty string when Line 6398 in bc3009a
What changes do you think we should make in order to solve the problem?When the currency is not passed from the report details, the function had a default value that cover this issue. Line 100 in bc3009a
but the issue is from the parent function Line 6398 in bc3009a
When We should pass - CurrencyUtils.convertToDisplayString(unheldTotal, iouReport?.currency ?? '')
+ CurrencyUtils.convertToDisplayString(unheldTotal, iouReport?.currency) What alternative solutions did you explore?We ned to add a logic to prevent using a non supported currency here Line 102 in a015db7
To handle invalid currency codes gracefully, we can use a try-catch block within your convertToDisplayString function. This will allow us to catch the RangeError and provide a default or fallback behavior. Additionally, we can validate the currency code before passing it to the NumberFormat constructor by checking against a list of supported currencies. Here's an updated version of your function: /**
* Given an amount in the "cents", convert it to a string for display in the UI.
* The backend always handle things in "cents" (subunit equal to 1/100)
*
* @param amountInCents – should be an integer. Anything after a decimal place will be dropped.
* @param currency - IOU currency
*/
function convertToDisplayString(amountInCents = 0, currency: string = CONST.CURRENCY.USD): string {
const convertedAmount = convertToFrontendAmount(amountInCents);
try {
return NumberFormatUtils.format(BaseLocaleListener.getPreferredLocale(), convertedAmount, {
style: 'currency',
currency,
// We are forcing the number of decimals because we override the default number of decimals in the backend for RSD
// See: https://github.com/Expensify/PHP-Libs/pull/834
minimumFractionDigits: currency === 'RSD' ? getCurrencyDecimals(currency) : undefined,
});
} catch (error) {
if (error instanceof RangeError) {
console.error(`Invalid currency code: ${currency}`, error);
// Provide a fallback display string or handle the error as needed
return `${convertedAmount} (Invalid currency)`;
} else {
throw error; // Re-throw unexpected errors
}
}
} |
Proposal Updated
|
@mountiny, whats the expected behaviour? What should we do when invalid currency is detected? |
ProposalPlease re-state the problem that we are trying to solve in this issue.[UX Reliability] App Crash with Invalid Currency code What is the root cause of that problem?
If we pass an invalid key say So the real issue relies on sending empty currency code which is happening here Lines 6362 to 6376 in 926d7af
If we observe here we're passing empty string here which can cause application break. What changes do you think we should make in order to solve the problem?So, to solve this we have to ensure we never pass empty currency i.e empty string code to the function here Line 6373 in 926d7af
we can make Line 100 in 1332a1c
And then in the function instead of directly using the passed code we can use the What alternative solutions did you explore? (Optional)Sometimes we might get empty string (maybe from backend) so at that time we cannot do anything to face it, as proposed we can make the |
I think we should be ok to default to USD in this case as it should be very rare and its probably some malformed data |
Damn this is killing me today. Would love to get it fixed. Having to right click > Mark as read a lot |
Proposal updated after this comment |
ProposalPlease re-state the problem that we are trying to solve in this issue.Invalid/missing currency code is not handled. What is the root cause of that problem?We don't have any mechanism to fallback to USD when the currency is missing or it is invalid. What changes do you think we should make in order to solve the problem?Updated logic in NumberFormatUtils to handle this issue (it can be polished):
If style is currency, then we will check for missing/invalid value. If we don't want to have the check directly in this file, then we can move it to the calling functions. |
Reviewing now |
I have this problem too |
PR has been created and QA is on-going 👍 |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.81-11 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 2024-06-18. 🎊 For reference, here are some details about the assignees on this issue:
|
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:
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.82-4 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 2024-06-20. 🎊 For reference, here are some details about the assignees on this issue:
|
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:
|
@ahmedGaber93 can you complete the checklist before EOD today so we're not delayed with payment tomorrow? Thanks! |
@CortneyOfstad doesn't the payment due date is yesterday which is the first that the resolution is deployed on? |
Also about the amount, shouldn't this come under critical issues which are eligible for 500$? I'm sorry if it's not! |
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:
Regression Test Proposal
extra steps for Web and Desktop only
Do we agree 👍 or 👎 |
Payment Summary@ahmedGaber93 — paid $500 (Critical) via Upwork Regression |
Upwork job price has been updated to $500 |
Heads up, in case anyone uses this as a reference for prices increases for 'critical' type issues. From #expensify-open-source
|
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number:
Reproducible in staging?:
Reproducible in production?:
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
Expensify/Expensify Issue URL:
Issue reported by: @joekaufmanexpensify
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1717433997016439
Action Performed:
Break down in numbered steps
Expected Result:
Describe what you think should've happened
We will handle this issue gracefully
Actual Result:
Describe what actually happened
The app crashes
Workaround:
Can the user still use Expensify without this being fixed? Have you informed them of the workaround?
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
View all open jobs on GitHub
Issue Owner
Current Issue Owner: @Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @CortneyOfstadThe text was updated successfully, but these errors were encountered: