You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$250] Tag - No error when creating new tag with existing name when tag name has X: Y format #45067
Version Number: 9.0.5-5 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail:https://expensify.testrail.io/index.php?/tests/view/4704925 Issue reported by: Applause - Internal Team
Action Performed:
Go to staging.new.expensify.com
Go to Workspace settings > Tag
Add a tag in X: Y format
Click Add tag
Attempt to add the same tag in Step 3
Note that there is no error that the same tag already exists
Create a different tag
Click on the tag in Step 7
Rename it to the same tag in Step 3 and save it
Note that there is no error too and the old tag in Step 7 is gone
Expected Result:
When the tag name has X: Y format, there will be error indicating that the same tag already exists when creating a new tag with the same name (Step 5) and renaming tag to the existing tag name (Step 10)
Actual Result:
When the tag name has X: Y format, no error when creating a new tag with the same name (Step 5) and renaming tag to the same name (Step 10)
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
@mallenexpensify FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors
Please re-state the problem that we are trying to solve in this issue.
There is no tag existing error when trying to add or edit a tag in X: Y format.
What is the root cause of that problem?
When we add a tag in X: Y format, the colon (:) is escaped, so it becomes X\: Y. When we check whether there is an existing tag, we just use the tag name input from the user without escaping it.
Also, there is another issue where adding x:y and x\:y tags will show both tags as x:y in the tag list, confusing the user. It's because the code replaces \: or \\: with : from the tag name.
Please re-state the problem that we are trying to solve in this issue.
No error when creating new tag with existing name when tag name has X: Y format
What is the root cause of that problem?
When a new tag is added and the tag string contain a colon : the backend will store it on Onyx adding a \ before the colon. So when we add a new tag that contain a colon, we need to check if it exist in the Onyx value. The issue is that the tags on Onyx has a \ added. And currently we are not checking the new tag with the \ similar to what we have stored on Onyx.
We have a function escapeTagName that takes a tag string with : and add the \ to make it similar to the Onyx values. We can use it in the comparisation.
Input: is the value entered on the input form when addinga new tag
Onyx: how the new tag will be stored on the database
Escaped: the input value passed throw the escapeTagName function
Displayed: how the value will be displayed for the user on the tags list page
Test
Input
Onyx
Escaped
Displayed
1
a: a
a\: a
a\: a
a: a
2
b\: b
b\\: b
b\\: b
b: b
3
c\\: c
c\\\: c
c\\\: c
c\: c
4
d\\\: d
d\\\\: d
d\\\\: d
d\\: d
On Test 1, if the user type something in the form of X: Y we can use the escapeTagName to make sure we don't get a duplicate, as we notice from the table, the Onyx value is equal to the Escaped value, same for the input value and the displayed value. So, X: Y will not be repeated.
But on Test 3, if the user type when adding a new tag c\\: c the displayed value will be different. Comparing the escapeTagName with the Onyx value will show that the value already exist but it doesn't. Because the displayed value is not as the one on the input, it's different value c\: c.
So, as we notice, using escapeTagName to compare the Onyx value with the new tag is correct is just some cases where the new tag string have only a colon, but when the user use a colon and lore than a \ in the new tag value , the comparisation using escapeTagName will not be correct. The error will display that those new tag already exists but it doesn't.
What changes do you think we should make in order to solve the problem?
As mentioned, using escapeTagName to compare the Onyx value with the new tag value will solve only some cases like Test 1 and Test 2, but in more complex examples like Test 3 and Test 4, the comparisation using escapeTagName will display wrong results.
To make a fair comparisation between the value of the new tag and the one displayed using values from Onyx, we should follow a better path. One way to do that is by:
Take all the tags from Onyx and convert those values to an array with value similar to the tags displayed
Compare the new tag string to the new tags array:
Now we have a new array with the same values displayed, we can compare the entered new tag string with those values and make sure no value will be similar to the one from the input.
changed the title [-]Tag - No error when creating new tag with existing name when tag name has X: Y format[/-][+][$250] Tag - No error when creating new tag with existing name when tag name has X: Y format[/+]on Jul 11, 2024
Contributor: @bernhardoj due $250 via NewDot
Contributor+: @getusha due $250 via NewDot
@getusha we want a regression test here, right? Assuming so, plz complete the BZ checklist below. Thx
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 PR that introduced the bug has been identified. Link to the PR:
[@] 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:
[@] 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:
[@] Determine if we should create a regression test for this bug.
[@] 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.
[@bz] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
[@] The PR that introduced the bug has been identified. Link to the PR: I wouldn't call this a regression at it seems to be an edge case that must've been missed on feature implementation.
[@] 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: N/a
[@] 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: N/a
[@] Determine if we should create a regression test for this bug. Yes
[@] 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
Open the app
Go to Workspace settings > Tag
Add X:Y tag
Attempt to add the same tag X:Y
Verify A tag with this name already exists error appears
Add a different tag
Click on the tag in Step 6
Rename it to the same tag in Step 3 (X:Y) and save it
Verify A tag with this name already exists error appears
Activity
melvin-bot commentedon Jul 9, 2024
Triggered auto assignment to @mallenexpensify (
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.lanitochka17 commentedon Jul 9, 2024
@mallenexpensify FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors
lanitochka17 commentedon Jul 9, 2024
We think that this bug might be related to #wave-collect - Release 1
bernhardoj commentedon Jul 9, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
There is no tag existing error when trying to add or edit a tag in X: Y format.
What is the root cause of that problem?
When we add a tag in X: Y format, the colon (:) is escaped, so it becomes
X\: Y. When we check whether there is an existing tag, we just use the tag name input from the user without escaping it.App/src/pages/workspace/tags/WorkspaceCreateTagPage.tsx
Lines 48 to 49 in 9c32293
For example, if we input
a: b, the tag will be saved asa\: b. When we try to adda: bagain, it will check ifa: bexists or not which doesn't.What changes do you think we should make in order to solve the problem?
Escape the tag name before doing the comparison.
App/src/pages/workspace/tags/WorkspaceCreateTagPage.tsx
Lines 43 to 49 in 9c32293
PolicyUtils.escapeTagName(values.tagName.trim())We need to do the same for edit tag page.
Also, there is another issue where adding
x:yandx\:ytags will show both tags asx:yin the tag list, confusing the user. It's because the code replaces\:or\\:with:from the tag name.App/src/libs/PolicyUtils.ts
Lines 289 to 291 in 9cd3257
To fix it, we only want to replace
\:with:.tag?.replace(/\\:/g, CONST.COLON);devguest07 commentedon Jul 9, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
No error when creating new tag with existing name when tag name has X: Y format
What is the root cause of that problem?
When a new tag is added and the tag string contain a colon
:the backend will store it on Onyx adding a\before the colon. So when we add a new tag that contain a colon, we need to check if it exist in the Onyx value. The issue is that the tags on Onyx has a\added. And currently we are not checking the new tag with the\similar to what we have stored on Onyx.We have a function
escapeTagNamethat takes a tag string with:and add the\to make it similar to the Onyx values. We can use it in the comparisation.App/src/libs/PolicyUtils.ts
Line 295 in 1534ac2
Below a table with some tests I have done:
escapeTagNamefunctiona: aa\: aa\: aa: ab\: bb\\: bb\\: bb: bc\\: cc\\\: cc\\\: cc\: cd\\\: dd\\\\: dd\\\\: dd\\: dOn Test 1, if the user type something in the form of
X: Ywe can use theescapeTagNameto make sure we don't get a duplicate, as we notice from the table, the Onyx value is equal to the Escaped value, same for the input value and the displayed value. So,X: Ywill not be repeated.But on Test 3, if the user type when adding a new tag
c\\: cthe displayed value will be different. Comparing theescapeTagNamewith the Onyx value will show that the value already exist but it doesn't. Because the displayed value is not as the one on the input, it's different valuec\: c.So, as we notice, using
escapeTagNameto compare the Onyx value with the new tag is correct is just some cases where the new tag string have only a colon, but when the user use a colon and lore than a\in the new tag value , the comparisation usingescapeTagNamewill not be correct. The error will display that those new tag already exists but it doesn't.What changes do you think we should make in order to solve the problem?
As mentioned, using
escapeTagNameto compare the Onyx value with the new tag value will solve only some cases like Test 1 and Test 2, but in more complex examples like Test 3 and Test 4, the comparisation usingescapeTagNamewill display wrong results.To make a fair comparisation between the value of the new tag and the one displayed using values from Onyx, we should follow a better path. One way to do that is by:
App/src/pages/workspace/tags/WorkspaceCreateTagPage.tsx
Line 30 in 5ce4e60
As we do for the display, we can use
getCleanedTagNameto make sure we have the same values as displayed on the tags page.App/src/pages/workspace/tags/WorkspaceTagsPage.tsx
Line 107 in d576e28
Now we have a new array with the same values displayed, we can compare the entered new tag string with those values and make sure no value will be similar to the one from the input.
App/src/pages/workspace/tags/WorkspaceCreateTagPage.tsx
Line 48 in 5ce4e60
What alternative solutions did you explore?
[-]Tag - No error when creating new tag with existing name when tag name has X: Y format[/-][+][$250] Tag - No error when creating new tag with existing name when tag name has X: Y format[/+]melvin-bot commentedon Jul 11, 2024
Job added to Upwork: https://www.upwork.com/jobs/~0126cdffc6828dd304
melvin-bot commentedon Jul 11, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @getusha (
External)49 remaining items
mallenexpensify commentedon Aug 26, 2024
@bernhardoj, @getusha can you provide and update on where we're at here? I think payment is due now cuz the second PR hit production over a week ago.
And, with/for the first PR, I see
So that doesn't seems like it was a regression.
bernhardoj commentedon Aug 26, 2024
@mallenexpensify yes, I believe it's now ready for payment.
Correct.
mallenexpensify commentedon Aug 26, 2024
Contributor: @bernhardoj due $250 via NewDot
Contributor+: @getusha due $250 via NewDot
@getusha we want a regression test here, right? Assuming so, plz complete the BZ checklist below. Thx
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:
techievivek commentedon Aug 29, 2024
Gentle bump @getusha on above.
techievivek commentedon Aug 29, 2024
Not overdue.
getusha commentedon Aug 29, 2024
[@] The PR that introduced the bug has been identified. Link to the PR: I wouldn't call this a regression at it seems to be an edge case that must've been missed on feature implementation.
[@] 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: N/a
[@] 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: N/a
[@] Determine if we should create a regression test for this bug. Yes
[@] 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
X:YtagX:YA tag with this name already existserror appearsX:Y) and save itA tag with this name already existserror appearsDo we agree 👍 or 👎
techievivek commentedon Aug 30, 2024
Looks good, @mallenexpensify let's get it added to testRail, thanks.
bernhardoj commentedon Aug 30, 2024
Requested in ND.
JmillsExpensify commentedon Aug 30, 2024
$250 approved for @bernhardoj
mallenexpensify commentedon Aug 30, 2024
We good here! Test case created