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

[Payment Due June 21] [$250] Can't open tag with tag name with % special characters #42549

Closed
6 tasks done
m-natarajan opened this issue May 23, 2024 · 41 comments
Closed
6 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Weekly KSv2

Comments

@m-natarajan
Copy link

m-natarajan commented May 23, 2024

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


Version Number: 1.4.75-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
Expensify/Expensify Issue URL:
Issue reported by: @DylanDylann
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1716460972676239

Action Performed:

  1. Sign into https://staging.new.expensify.com/
  2. Click Account Settings > Workspace > More Features > tags
  3. Create a tag name !@#$%^&(&^%$#@ (it seems to be the `%' that throws the error'
  4. Save the Tag > Click on the tag again - notice the "uh-oh, something went wrong!" error

Expected Result:

The user should access to tag setting page

Actual Result:

App crashes - notice the "uh-oh, something went wrong!" error

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

Recording.17.mp4
2024-05-27_16-04-06.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01e766d47beaa045bb
  • Upwork Job ID: 1795004446572822528
  • Last Price Increase: 2024-05-27
  • Automatic offers:
    • DylanDylann | Reviewer | 102522628
Issue OwnerCurrent Issue Owner: @
Issue OwnerCurrent Issue Owner: @
Issue OwnerCurrent Issue Owner: @DylanDylann
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels May 23, 2024
Copy link

melvin-bot bot commented May 23, 2024

Triggered auto assignment to @Christinadobrzyn (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@abzokhattab
Copy link
Contributor

abzokhattab commented May 23, 2024

Proposal

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

app crashes when opening a tag with a name having special characters

What is the root cause of that problem?

getRoute: (policyID: string, tagName: string) => `settings/workspaces/${policyID}/tag/${encodeURIComponent(tagName)}` as const,

  • then on clicking on navigating to the tag settings, the tagName is parsed back to the original value using decodeURIComponent inside the navigation configs
    },
    [SCREENS.WORKSPACE.TAG_SETTINGS]: {
    path: ROUTES.WORKSPACE_TAG_SETTINGS.route,
    parse: {
    tagName: (tagName: string) => decodeURIComponent(tagName),
    },
  • finally inside the TagSettingsPage
    the route.params.tagName is wrongly decoded again causing the decode function to throw an error:
    const currentPolicyTag =
    policyTag.tags[decodeURIComponent(route.params.tagName)] ?? Object.values(policyTag.tags ?? {}).find((tag) => tag.previousTagName === decodeURIComponent(route.params.tagName));

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

there is no need to decode the tagName inside the TagSettingsPage since the value is already parsed back to the original value inside the navigation config,

so we should modify this to:

    const currentPolicyTag = policyTag.tags[route.params.tagName] ?? Object.values(policyTag.tags ?? {}).find((tag) => tag.previousTagName === route.params.tagName);

POC

Screen.Recording.2024-05-27.at.10.47.53.AM.mov

@DylanDylann
Copy link
Contributor

I reported this bug from here, I would love to take over this issue as C+ if this is external

@Christinadobrzyn

This comment was marked as outdated.

@Christinadobrzyn
Copy link
Contributor

@DylanDylann do you think this might be related? #41414

@DylanDylann
Copy link
Contributor

@Christinadobrzyn The original bug can still be reproduced. Please try again with this name: !@#$%^&*(*&^%$#@

@DylanDylann
Copy link
Contributor

@Christinadobrzyn I can't reproduce your bug here. Could you copy exactly 2 tag names used in your video?

@Christinadobrzyn Christinadobrzyn changed the title Can't open tag with tag name with special characters Can't open tag with tag name with % special characters May 27, 2024
@Christinadobrzyn
Copy link
Contributor

Christinadobrzyn commented May 27, 2024

Ah thanks @DylanDylann - I can reproduce with !@#$%^&*(*&^%$#@ (I think it's just the % that's causing the error). Updated the OP. Do you think this can be external? Do you think this is related - #41414 - seems to be the same error

@DylanDylann
Copy link
Contributor

I checked this bug before reporting it. This is a bug from the front end. Let's make it external

@Christinadobrzyn Christinadobrzyn added the External Added to denote the issue can be worked on by a contributor label May 27, 2024
@melvin-bot melvin-bot bot changed the title Can't open tag with tag name with % special characters [$250] Can't open tag with tag name with % special characters May 27, 2024
Copy link

melvin-bot bot commented May 27, 2024

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

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

melvin-bot bot commented May 27, 2024

Current assignee @DylanDylann is eligible for the External assigner, not assigning anyone new.

@DylanDylann
Copy link
Contributor

Do you think this is related - #41414 - seems to be the same error

@Christinadobrzyn This is different from #41414

@ShridharGoel
Copy link
Contributor

ShridharGoel commented May 27, 2024

Proposal

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

Can't open tag name and can't edit tag name with special characters like %.
Also, can't edit any category name to add a special character.

What is the root cause of that problem?

Encoding is being done while creating the route:

App/src/ROUTES.ts

Lines 674 to 681 in 525ad6f

WORKSPACE_TAG_EDIT: {
route: 'settings/workspace/:policyID/tag/:tagName/edit',
getRoute: (policyID: string, tagName: string) => `settings/workspace/${policyID}/tag/${encodeURIComponent(tagName)}/edit` as const,
},
WORKSPACE_TAG_SETTINGS: {
route: 'settings/workspaces/:policyID/tag/:tagName',
getRoute: (policyID: string, tagName: string) => `settings/workspaces/${policyID}/tag/${encodeURIComponent(tagName)}` as const,
},

Then, decoding is being done:

[SCREENS.WORKSPACE.TAG_EDIT]: {
path: ROUTES.WORKSPACE_TAG_EDIT.route,
parse: {
tagName: (tagName: string) => decodeURIComponent(tagName),
},
},
[SCREENS.WORKSPACE.TAG_SETTINGS]: {
path: ROUTES.WORKSPACE_TAG_SETTINGS.route,
parse: {
tagName: (tagName: string) => decodeURIComponent(tagName),
},
},

But, in the TagSettingsPage, decoding is being done again which leads to issue of URI malformed exception because the tagName is already decoded.

const currentPolicyTag =
policyTag.tags[decodeURIComponent(route.params.tagName)] ?? Object.values(policyTag.tags ?? {}).find((tag) => tag.previousTagName === decodeURIComponent(route.params.tagName));

Also, the same issue happens when editing a category name to use special characters because optimistic data, success data and failure data use the decode method on already decoded category name.

unencodedName: decodeURIComponent(policyCategory.newName),

unencodedName: decodeURIComponent(policyCategory.newName),

unencodedName: decodeURIComponent(policyCategory.oldName),

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

Update to remove decodeURIComponent from the below places:

const currentPolicyTag =
        policyTag.tags[route.params.tagName] ?? Object.values(policyTag.tags ?? {}).find((tag) => tag.previousTagName === route.params.tagName);
function renamePolicyCategory(policyID: string, policyCategory: {oldName: string; newName: string}) {
    const policyCategoryToUpdate = allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`]?.[policyCategory.oldName] ?? {};

    const onyxData: OnyxData = {
        optimisticData: [
            {
                onyxMethod: Onyx.METHOD.MERGE,
                key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`,
                value: {
                    [policyCategory.oldName]: null,
                    [policyCategory.newName]: {
                        ...policyCategoryToUpdate,
                        name: policyCategory.newName,
-                       unencodedName: decodeURIComponent(policyCategory.newName),
+                      unencodedName: policyCategory.newName,
                        pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
                        pendingFields: {
                            name: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
                        },
                        previousCategoryName: policyCategory.oldName,
                    },
                },
            },
        ],
        successData: [
            {
                onyxMethod: Onyx.METHOD.MERGE,
                key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`,
                value: {
                    [policyCategory.oldName]: null,
                    [policyCategory.newName]: {
                        ...policyCategoryToUpdate,
                        name: policyCategory.newName,
-                      unencodedName: decodeURIComponent(policyCategory.newName),
+                      unencodedName: policyCategory.newName,
                        errors: null,
                        pendingAction: null,
                        pendingFields: {
                            name: null,
                        },
                    },
                },
            },
        ],
        failureData: [
            {
                onyxMethod: Onyx.METHOD.MERGE,
                key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`,
                value: {
                    [policyCategory.newName]: null,
                    [policyCategory.oldName]: {
                        ...policyCategoryToUpdate,
                        name: policyCategory.oldName,
-                      unencodedName: decodeURIComponent(policyCategory.oldName),
+                      unencodedName: policyCategory.oldName,
                        errors: ErrorUtils.getMicroSecondOnyxError('workspace.categories.updateFailureMessage'),
                        pendingAction: null,
                    },
                },
            },
        ],
    };

    const parameters = {
        policyID,
        categories: JSON.stringify({[policyCategory.oldName]: policyCategory.newName}),
    };

    API.write(WRITE_COMMANDS.RENAME_WORKSPACE_CATEGORY, parameters, onyxData);
}

@truph01
Copy link
Contributor

truph01 commented May 27, 2024

Proposal

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

  • App crashes - notice the "uh-oh, something went wrong!" error.

  • We have the same problem when adding a special character and saving the category.

What is the root cause of that problem?

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

And remove it in the type object and tests too. This will help save the app's Onyx storage, and help us get rid of unused tech debt.

What alternative solutions did you explore? (Optional)

NA

@Christinadobrzyn
Copy link
Contributor

Awesome - we have some proposals to review when you have a moment @DylanDylann!

@DylanDylann
Copy link
Contributor

Sure, I will review proposals by the end of today or tomorrow

@truph01
Copy link
Contributor

truph01 commented May 28, 2024

I updated the proposal a bit to fix a malformed permalink

@DylanDylann
Copy link
Contributor

DylanDylann commented May 29, 2024

All proposals work well. I prefer @truph01's proposal because they also address the bug on the category page with an appropriate solution

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented May 29, 2024

Triggered auto assignment to @lakchote, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@ShridharGoel
Copy link
Contributor

@DylanDylann Is it sure that unencodedName needs to be removed?

@truph01
Copy link
Contributor

truph01 commented May 29, 2024

@ShridharGoel It's unused in the codebase so there's no reason to keep it. The back-end also doesn't return that field, it just exists in optimistic data.

@Christinadobrzyn Christinadobrzyn added Weekly KSv2 and removed Daily KSv2 labels Jun 12, 2024
@Christinadobrzyn
Copy link
Contributor

Ah okay, let me see if I can get someone else to review the PR. Asking the team - https://expensify.slack.com/archives/C066HJM2CAZ/p1718180871595969

@Christinadobrzyn
Copy link
Contributor

Christinadobrzyn commented Jun 13, 2024

Just a heads up - I'm going to be ooo until June 24th so going to assign a teammate to watch this while I'm away

@JmillsExpensify you're perfect for this! we're trying to find an engineer to review the PR while @lakchote is ooo. Could you help us find a volunteer?

@Christinadobrzyn Christinadobrzyn removed the Bug Something is broken. Auto assigns a BugZero manager. label Jun 13, 2024
@Christinadobrzyn Christinadobrzyn removed their assignment Jun 13, 2024
@Christinadobrzyn Christinadobrzyn added the Bug Something is broken. Auto assigns a BugZero manager. label Jun 13, 2024
Copy link

melvin-bot bot commented Jun 13, 2024

Triggered auto assignment to @JmillsExpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jun 13, 2024
@Christinadobrzyn Christinadobrzyn self-assigned this Jun 13, 2024
@DylanDylann
Copy link
Contributor

The PR is merged. Waiting for deploying to production

@DylanDylann
Copy link
Contributor

@JmillsExpensify The PR is deployed to production 4 days ago. Please update the status of this issue

@mvtglobally
Copy link

Issue not reproducible during KI retests. (First week)

@Christinadobrzyn Christinadobrzyn changed the title [$250] Can't open tag with tag name with % special characters [Payment Due June 21] [$250] Can't open tag with tag name with % special characters Jun 24, 2024
@Christinadobrzyn
Copy link
Contributor

Christinadobrzyn commented Jun 24, 2024

Looks like the PR was deployed into production on June 14 so the 7 day hold ended on June 21st. This is due for payment. correct? @DylanDylann

Payouts due:

Upwork job is here.

@DylanDylann do we need a regression test for this?

@Christinadobrzyn
Copy link
Contributor

@truph01 can you please accept the Upwork offer - #42549 (comment)

@DylanDylann do we need a regression test for this?

@DylanDylann
Copy link
Contributor

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:

[@DylanDylann] The PR that introduced the bug has been identified. Link to the PR: NA
[@DylanDylann] 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: NA
[@DylanDylann] 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: NA
[@DylanDylann] Determine if we should create a regression test for this bug. Yes
[@DylanDylann] 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.

Regression Test Proposal

  1. Open app
  2. Click Account Settings > Workspace > More Features > tags
  3. Create a tag name !@#$%^&(&^%$#@ (it seems to be the `%' that throws the error'
  4. Save the Tag > Click on the tag again - notice the "uh-oh, something went wrong!" error
  5. Observe that the user should access to tag setting page

Do we agree 👍 or 👎

@Christinadobrzyn
Copy link
Contributor

Regression test - https://github.com/Expensify/Expensify/issues/408381

Waiting on finalising payment - #42549 (comment)

@Christinadobrzyn Christinadobrzyn removed Reviewing Has a PR in review Help Wanted Apply this label when an issue is open to proposals by contributors labels Jun 27, 2024
@Christinadobrzyn
Copy link
Contributor

This is done other than the payment to @truph01.

Moving this to weekly to wait for @truph01 to accept offer - https://www.upwork.com/nx/wm/offer/102802999

@melvin-bot melvin-bot bot added the Overdue label Jun 28, 2024
@Christinadobrzyn Christinadobrzyn added Weekly KSv2 and removed Daily KSv2 labels Jun 28, 2024
@melvin-bot melvin-bot bot removed the Overdue label Jun 28, 2024
@truph01
Copy link
Contributor

truph01 commented Jul 1, 2024

@Christinadobrzyn Offer accepted, sorry for the delay 🙏

@Christinadobrzyn
Copy link
Contributor

Thanks @truph01 - paid out based on this payment summary - #42549 (comment)

Closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Weekly KSv2
Projects
Archived in project
Development

No branches or pull requests

9 participants