Skip to content

[Due for payment 2025-04-08] [$250] Tags - While adding specific tag, error occured while updating the tag is displayed. #58845

Closed

Description

@jponikarchuk

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: V9.1.16-1
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Yes, reproducible on both
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): Slottwo1 fear3@gmail.com
Issue reported by: Applause Internal Team
Device used: Redminote 10s android 13 phone
App Component: Workspace Settings

Action Performed:

  1. Launch app
  2. Go to workspace settings > more features > enable tags
  3. Tap tags > add tag
  4. Paste the text - cjwhwh😙😥🥺😄🥰☺️🥲☺️jj😆🥲😆🥰😆🥰😆🥲kjjjhOgifjxhdzgzgzgngmgngmggmzmkggkkgKgYkysudjcxiixxuids7us&h,hztUratsyhxxhuzsusu7s6ssuuzys6a5a5aittayszh6s6ww67shszuyswuyw7sxuduuduxxiciixifjdvjrvnejej jw jsj js jwh hwcjwhwh😙😥🥺😄🥰☺️🥲☺️🥲🥲👋🥰😆🥲😆🥰😆🥰😆🥲
  5. Save the tag

Expected Result:

  1. Ideally, the error message should be as informative as the one throwing ([<redacted because it's massive> is invalid. Please don't use any special characters.)
  2. When dismissing an error message for the tag upload failure, the tag value should disappear.

Bonus: The regex in Web-E says we do support special characters, so perhaps a specific emoji is causing the issue and we can catch it as touched on here.

Actual Result:

  1. The error message doesn't match the one that throws (An error occurred while updating the tag, please try again.)
  2. The tag value doesn't disappear when dismissing the error message.
  3. An error occurs for this specific tag value, though we do support special characters in tag values it seems.

Investigated a bit in this comment thread if it's helpful.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

2025-03-21_00-05-46.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021902874693859961671
  • Upwork Job ID: 1902874693859961671
  • Last Price Increase: 2025-03-21
Issue OwnerCurrent Issue Owner: @trjExpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Mar 20, 2025
  2. melvin-bot commented on Mar 20, 2025

    @melvin-bot

    Triggered auto assignment to @trjExpensify (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.

  3. trjExpensify commented on Mar 20, 2025

    @trjExpensify
    Contributor

    Kinda' ridiculous tag that haha. Couple of things though:

    • The tag value should disappear upon dismissing the error message, that's not happening.
    • The error message I see in the logs is more informative, why isn't it being displayed in NewDot?
    API threw ExpError Expensify\Libs\Error\ExpError - e45838d8-1f79-11e5-b5f7-727283247c7f ~~ onyxData: '[0: '[onyxMethod: 'merge' key: 'policyTags_' value: '[<redacted because it's massive> is invalid. Please don't use any special characters.' exceptionMessage: 'Oops... The format of the tag <redacted because it's massive> is invalid. Please don't use any special characters.' exceptionFile: '/git/releases/expensify.com/f5cce8f/lib/PolicyAPI.php' exceptionLine: '2139' exceptionCode: '666'
    

    The error throws here.

    The regex being:

    !preg_match("/^[^\r\n\t]{1,256}$/"
    
    • The error message says it's because special characters are being used but entering in a few others with emojis and special characters works fine and are valid. So I think it's a specific emoji in that monstrosity that might be causing it to throw. ChatGPT seems to agree:
    Image

    With these possible fixes:

    Image

    In terms of next steps then:

    • I'm kinda' okay to not update the regex in Web-E to account for this, though happy to take the opinion of the internal engineer that gets assigned eventually. Might be quick.
    • I do however think we should ensure the tag value is removed on dismissing the error message, because that's a standard pattern.
    • It would also be good to know why the specific error message about special characters isn't showing. Maybe that's because on the surface it's "valid", but something with a specific emoji there is causing it to throw.
  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Mar 21, 2025
  5. changed the title [-]Tags - While adding specific tag, error occured while updating the tag is displayed.[/-] [+][$250] Tags - While adding specific tag, error occured while updating the tag is displayed.[/+] on Mar 21, 2025
  6. melvin-bot commented on Mar 21, 2025

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Mar 21, 2025
  8. moved this to Bugs and Follow Up Issues in #expensify-bugson Mar 21, 2025
  9. melvin-bot commented on Mar 21, 2025

    @melvin-bot

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

  10. bernhardoj commented on Mar 21, 2025

    @bernhardoj
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-03-21 03:31:04 UTC.

    Proposal

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

    The informative error from the BE isn't shown and after dismissing the error, the tag isn't removed.

    What is the root cause of that problem?

    If we see the API response, the BE returns the error already, but it assigns the error to policyTags_ collection which is wrong. It should assign it to policyTags_{workspaceID}. Because of that, the generic error that is set on the FE is shown.

    Image

    For the 2nd issue, the tag should be removed when clearing the error when the pending action is add.

    function clearPolicyTagErrors(policyID: string, tagName: string, tagListIndex: number) {
    const tagListName = PolicyUtils.getTagListName(allPolicyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`], tagListIndex);
    const tag = allPolicyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`]?.[tagListName].tags?.[tagName];
    if (!tag) {
    return;
    }
    if (tag.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD) {
    Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`, {
    [tagListName]: {
    tags: {
    [tagName]: null,
    },
    },
    });
    return;
    }

    However, we clear the pending action when the request fails.

    failureData: [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`,
    value: {
    [policyTag.name]: {
    tags: {
    [newTagName]: {
    errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('workspace.tags.genericFailureMessage'),
    pendingAction: null,
    },

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

    The 1st issue should be fixed on the BE. For the 2nd issue, we shouldn't clear the pending action when fails.

    For the error itself, most likely it happens because of the exceeded character length. To improve the validation, we can calculate the length using text encoder.

    const textEncoder = new TextEncoder();
    textEncoder.encode(tagName).length
    

    If we apply this, then we won't be able to trigger the error anymore.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    We can create a test for createPolicyTag, make it fails and assert that the pending action is still there (add).

  11. bernhardoj commented on Mar 21, 2025

    @bernhardoj
    Contributor

    The error message says it's because special characters are being used but entering in a few others with emojis and special characters works fine and are valid. So I think it's a specific emoji in that monstrosity that might be causing it to throw.

    Looks like the error is all about exceeding the maximum length. Using this https://mothereff.in/byte-counter, we can see the (bytes) length of the tag. If we input

    cjwhwhjj😆🥲😆😆🥲😆😆🥲😆😆🥲😆😆🥲😆😆🥲😆kjjjhOgifjxhdzgzgzgngmgngmggmzmkggkkgKgYkysudjcxiixxuids7us&h,hztUratsyhxxhuzsusu7s6ssuuzys6a5a5aittayszh6s6ww67shszuyswuyw7sxuduuduxxiciixifjdvjrvnejej jw jsj jsaaaaaaaaaaaaab
    

    then it's fine because it's 256 long. But if we add another character (so it's 257 long), then it will give an error.

  12. 28 remaining items

  13. melvin-bot commented on Apr 1, 2025

    @melvin-bot

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

  14. melvin-bot commented on Apr 1, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.21-3 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 2025-04-08. 🎊

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

    • @s77rt requires payment through NewDot Manual Requests
    • @bernhardoj requires payment through NewDot Manual Requests
  15. melvin-bot commented on Apr 1, 2025

    @melvin-bot

    @s77rt @trjExpensify @s77rt The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  16. s77rt commented on Apr 7, 2025

    @s77rt
    Member

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [Contributor] 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: Add a switch for requiring tags on the multi level tags RHP #42972 (comment)

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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: n/a

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

      Bug requires regression test: Yes

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Precondition:

    • Have workspace with tags and categories enabled

    Test:

    Tags:

    1. Go to a workspace tags page
    2. Add a tag with a very long invalid name e.g. cjwhwh😙😥🥺😄🥰☺️🥲☺️jj😆🥲😆🥰😆🥰😆🥲kjjjhOgifjxhdzgzgzgngmgngmggmzmkggkkgKgYkysudjcxiixxuids7us&h,hztUratsyhxxhuzsusu7s6ssuuzys6a5a5aittayszh6s6ww67shszuyswuyw7sxuduuduxxiciixifjdvjrvnejej jw jsj js jwh hwcjwhwh😙😥🥺😄🥰☺️🥲☺️🥲🥲👋🥰😆🥲😆🥰😆🥰😆🥲
    3. Verify that you see an error below the added tag
    4. Clear the error
    5. Verify that the error is cleared
    6. Verify that the added tag is removed

    Categories

    1. Go to a workspace categories page
    2. Add a category with a very long invalid name e.g. cjwhwh😙😥🥺😄🥰☺️🥲☺️jj😆🥲😆🥰😆🥰😆🥲kjjjhOgifjxhdzgzgzgngmgngmggmzmkggkkgKgYkysudjcxiixxuids7us&h,hztUratsyhxxhuzsusu7s6ssuuzys6a5a5aittayszh6s6ww67shszuyswuyw7sxuduuduxxiciixifjdvjrvnejej jw jsj js jwh hwcjwhwh😙😥🥺😄🥰☺️🥲☺️🥲🥲👋🥰😆🥲😆🥰😆🥰😆🥲
    3. Verify that you see an error below the added category
    4. Clear the error
    5. Verify that the error is cleared
    6. Verify that the added category is removed

    Do we agree 👍 or 👎

  17. melvin-bot commented on Apr 8, 2025

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@trjExpensify)

    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1902874693859961671/hired)
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  18. trjExpensify commented on Apr 15, 2025

    @trjExpensify
    Contributor

    Hey, sorry for the delay. I've been OoO.

    Payment summary as follows:

    Go ahead and request! Closing!

  19. moved this from Bugs and Follow Up Issues to Done in #expensify-bugson Apr 15, 2025
  20. JmillsExpensify commented on Apr 15, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @s77rt

  21. bernhardoj commented on Apr 15, 2025

    @bernhardoj
    Contributor

    Requested in ND.

  22. JmillsExpensify commented on Apr 22, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @bernhardoj

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