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 2024-02-20] [$250] Address – Incorrect error message appear when enter Cyrillic letters into Zip field #34668

Closed
3 of 6 tasks
lanitochka17 opened this issue Jan 17, 2024 · 36 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 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@lanitochka17
Copy link

lanitochka17 commented Jan 17, 2024

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: 1.4.26-1
Reproducible in staging?: Y
Reproducible in production?: N
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: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Login to New dot
  2. Navigate to Settings -> Profile -> Personal details
  3. Navigate to Home address page
  4. Add Cyrillic letters or symbols into Zip/Postcode field

Expected Result:

"Incorrect zip code format" message should appear

Actual Result:

Incorrect error message ( privatePersonalDetails.error.incorrectZipFormat ) appear when enter Cyrillic letters into Zip/Postcode field

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6345666_1705518185161!Capture

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01ae2a56928644ce4f
  • Upwork Job ID: 1747794052740149248
  • Last Price Increase: 2024-01-18
  • Automatic offers:
    • s77rt | Reviewer | 28118027
    • dukenv0307 | Contributor | 28118028
@lanitochka17 lanitochka17 added the DeployBlockerCash This issue or pull request should block deployment label Jan 17, 2024
Copy link
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.

Copy link

melvin-bot bot commented Jan 17, 2024

Triggered auto assignment to @jasperhuangg (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@abzokhattab
Copy link
Contributor

abzokhattab commented Jan 17, 2024

Proposal

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

Address - Incorrect error message appear when enter Cyrillic letters into Zip field

What is the root cause of that problem?

  1. the zip code input is inside an input wrapper where the inputcomponent prop is TextInput
  2. inside the input wapper we call registerInput which is provided by the FormProvider context here
  3. the registerInput function sets the errorText ---> errorText: errors[inputID] || fieldErrorMessage,
  4. now the object returned from the registerInput is passed to the TextInput as props
  5. the BaseTextInput component uses FormHelpMessage to display the error where the input is the errorText provided in the props
  6. the FormHelpMessage component calls Localize.translateIfPhraseKey to translate the error message
  7. the translateIfPhraseKey function parses the input value to fetch the passed variables to the translate function
  8. in the case of the zipcode we don't provide a second argument to the translation making the variables object assigned to undefined which make the translate function unable to resolve the translation.

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

we can add an empty object as the default value for the variables obj here :

        const [phrase, variables = {}] = Array.isArray(message) ? message : [message];

alternatively

we can modify the zipcode translation above to:

errors.zipPostCode = ['privatePersonalDetails.error.incorrectZipFormat', {zipFormat: countryZipFormat}];

futhermore this snippet could be refactored to:

const trimmedZip = values.zipPostCode.trim().toUpperCase();
const zipValidation = countrySpecificZipRegex ? countrySpecificZipRegex.test(trimmedZip) : CONST.GENERIC_ZIP_CODE_REGEX.test(trimmedZip);
const isRequiredFulfilled = ValidationUtils.isRequiredFulfilled(values.zipPostCode.trim());

if (!zipValidation) {
    errors.zipPostCode = isRequiredFulfilled
        ? ['privatePersonalDetails.error.incorrectZipFormat', { zipFormat: countryZipFormat }]
        : 'common.error.fieldRequired';
}

@mountiny mountiny added External Added to denote the issue can be worked on by a contributor Daily KSv2 and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Jan 18, 2024
@melvin-bot melvin-bot bot changed the title Address – Incorrect error message appear when enter Cyrillic letters into Zip field [$500] Address – Incorrect error message appear when enter Cyrillic letters into Zip field Jan 18, 2024
Copy link

melvin-bot bot commented Jan 18, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01ae2a56928644ce4f

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 18, 2024
Copy link

melvin-bot bot commented Jan 18, 2024

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

@mountiny mountiny changed the title [$500] Address – Incorrect error message appear when enter Cyrillic letters into Zip field [$250] Address – Incorrect error message appear when enter Cyrillic letters into Zip field Jan 18, 2024
@mountiny mountiny added the Bug Something is broken. Auto assigns a BugZero manager. label Jan 18, 2024
Copy link

melvin-bot bot commented Jan 18, 2024

Upwork job price has been updated to $250

@ghost
Copy link

ghost commented Jan 18, 2024

Proposal

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

Address – Incorrect error message appear when enter Cyrillic letters into Zip field

What is the root cause of that problem?

The root cause of the problem is right now error message is having privatePersonalDetails.error.incorrectZipFormat error :

} else if (!CONST.GENERIC_ZIP_CODE_REGEX.test(values.zipPostCode.trim().toUpperCase())) {
errors.zipPostCode = 'privatePersonalDetails.error.incorrectZipFormat';

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

Here we need to enter the error message that we want to display i.e. Incorrect Zip Code Format

Screenshot of the output

Screenshot 2024-01-18 at 9 43 07 AM

What alternative solutions did you explore? (Optional)

The alternative approach can be updating the error.zipPostCode with the same code on line 106

errors.zipPostCode = ['privatePersonalDetails.error.incorrectZipFormat', {zipFormat: countryZipFormat}];

This will generate same output as this image.
Screenshot 2024-01-18 at 9 43 07 AM

@dukenv0307
Copy link
Contributor

dukenv0307 commented Jan 18, 2024

Proposal

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

Incorrect error message ( privatePersonalDetails.error.incorrectZipFormat ) appear when enter Cyrillic letters into Zip/Postcode field

What is the root cause of that problem?

This is regression from this change https://github.com/Expensify/App/pull/29742/files#diff-fe6e9abcee003c3390e38c0210d32ff889767cfab2c007837ed64c02147162e1

Earlier the phraseParameters is defaulted to {} here, so if phrase variables is not provided, it will default to {} and won't have any issue translating here since the zipFormat will be undefined and will not be used.

After that regression change, the phraseParameters doesn't have any default value so it will pass undefined to the translation function, leading to runtime error because it cannot find zipFormat prop from undefined param.

If we put the logs here, we can see the runtime error. And it will fallback to using the phraseKey when the error happens, causing this issue.

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

Default the phraseParameters to empty object like before the regression.
We can:

  • Rename phraseParameters to inputPhraseParameters here
  • Then add the default in the line below it like
const phraseParameters = inputPhraseParameters.length <= 1 && inputPhraseParameters[0] === undefined ? [{}] : inputPhraseParameters;

So if there's no inputPhraseParameters, it will be default to {} and the translation function will work like before.

Alternatively, we can remove the rest ... in there (and in translateLocal, ...) and default phraseParameters to {} like phraseParameters = {} here so that it will just use phraseParameters exactly like before.

What alternative solutions did you explore? (Optional)

Since zipFormat is an optional parameter, as can be seen in the translation
, we can refrain from using {zipFormat} because this is assuming that the input will be required. instead we can update this to

incorrectZipFormat: (params: IncorrectZipFormatParams) => `Incorrect zip code format.${params?.zipFormat ? ` Acceptable format: ${params?.zipFormat}` : ''}`,

So that it's clear the zipFormat is optional and not passing the params will not cause any problem. We can even omit the params as an object but instead pass in the zipFormat as a param directly.

We should do the same for all translation params that are "optional" as in this case.

@s77rt
Copy link
Contributor

s77rt commented Jan 19, 2024

I have asked if the change in the 3rd argument (the phrase parameters) is intended or not here https://github.com/Expensify/App/pull/29742/files#r1459284554. If we don't really need it we can just revert into using an object. Otherwise we'd add the missing parameters for translation that takes parameters.

@blazejkustra
Copy link
Contributor

@s77rt Answered here

@melvin-bot melvin-bot bot added the Overdue label Jan 22, 2024
@s77rt
Copy link
Contributor

s77rt commented Jan 22, 2024

@abzokhattab Thanks for the proposal. I didn't understand your RCA can you please rephrase?

@melvin-bot melvin-bot bot removed the Overdue label Jan 22, 2024
@s77rt
Copy link
Contributor

s77rt commented Jan 22, 2024

@AnshuAgarwal24 Thanks for the proposal. Your RCA is not correct. privatePersonalDetails.error.incorrectZipFormat is the translation key and it's correct.

@s77rt
Copy link
Contributor

s77rt commented Jan 22, 2024

@dukenv0307 Thanks for the proposal. Your RCA is correct. As for the solution I don't think it makes sense to define a default value for a multi-arguments input.

@abzokhattab
Copy link
Contributor

Should i improve it or you would assign duke for that? @s77rt .. we can infact use the optional params for other translations as well.

thanks

@s77rt
Copy link
Contributor

s77rt commented Jan 23, 2024

@abzokhattab I think it makes sense to assign @dukenv0307 if we will be going with his solution

@s77rt
Copy link
Contributor

s77rt commented Jan 23, 2024

I'm not sure why we defined a custom type for every translation key. Many of them only have one parameter, it's easier to just use the parameter directly.

type IncorrectZipFormatParams = {zipFormat?: string};
incorrectZipFormat: ({zipFormat}: IncorrectZipFormatParams) => ...
incorrectZipFormat: (zipFormat?: string) => ...

@abzokhattab
Copy link
Contributor

I believe we use objects for ease of use. In the other case you have to make sure that the passed variables are in the “correct” order .. i lean towards using objects for functions that have many arguments and use the other way in case you have few arguments

@dukenv0307
Copy link
Contributor

Can you please update your proposal for that?

@s77rt Sure! Proposal updated to include that as the alternate solution.

@s77rt
Copy link
Contributor

s77rt commented Jan 23, 2024

@dukenv0307 Thank you! Let's remove IncorrectZipFormatParams type as well. Using zipFormat as parameter is more readable.

🎀 👀 🎀 C+ reviewed
Link to proposal

Copy link

melvin-bot bot commented Jan 23, 2024

Current assignee @jasperhuangg is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 23, 2024
Copy link

melvin-bot bot commented Jan 23, 2024

📣 @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

Copy link

melvin-bot bot commented Jan 23, 2024

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

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Jan 26, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Feb 13, 2024
@melvin-bot melvin-bot bot changed the title [$250] Address – Incorrect error message appear when enter Cyrillic letters into Zip field [HOLD for payment 2024-02-20] [$250] Address – Incorrect error message appear when enter Cyrillic letters into Zip field Feb 13, 2024
Copy link

melvin-bot bot commented Feb 13, 2024

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Feb 13, 2024
Copy link

melvin-bot bot commented Feb 13, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.40-5 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-02-20. 🎊

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

Copy link

melvin-bot bot commented Feb 13, 2024

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.
  • [] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@s77rt
Copy link
Contributor

s77rt commented Feb 13, 2024

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Feb 20, 2024
Copy link

melvin-bot bot commented Feb 20, 2024

Issue is ready for payment but no BZ is assigned. @sonialiap you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks!

@sonialiap
Copy link
Contributor

@s77rt Reviewer $250 - paid ✔️
@dukenv0307 Contributor $250 - 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 Engineering External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

8 participants