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

[$125] Tag - Error occurs when trying to add a tag named "some" #50023

Open
2 of 6 tasks
IuliiaHerets opened this issue Oct 1, 2024 · 11 comments
Open
2 of 6 tasks

[$125] Tag - Error occurs when trying to add a tag named "some" #50023

IuliiaHerets opened this issue Oct 1, 2024 · 11 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Overdue

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Oct 1, 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: 9.0.42-0
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team

Action Performed:

  1. Go to https://staging.new.expensify.com/
  2. Create a workspace.
  3. Navigate to Workspace settings > more features > enable tags.
  4. Go to tags.
  5. Click on add tag.
  6. Name the tag "some" and try to save it. (ensure to write it in lowercase.)

Expected Result:

The tag named "some" should be successfully created and saved without any issues.

Actual Result:

The system returns an error stating 'A tag with this name already exists' even though no tag named 'some' is present, which might indicate a system error.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6621111_1727789514419.1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021841480841839544675
  • Upwork Job ID: 1841480841839544675
  • Last Price Increase: 2024-10-02
Issue OwnerCurrent Issue Owner: @allroundexperts
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 1, 2024
Copy link

melvin-bot bot commented Oct 1, 2024

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

@IuliiaHerets
Copy link
Author

We think that this bug might be related to #wave-collect - Release 1

@IuliiaHerets
Copy link
Author

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

@Nodebrute
Copy link
Contributor

Nodebrute commented Oct 1, 2024

Edited by proposal-police: This proposal was edited at 2024-10-01 20:48:11 UTC.

Proposal

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

Error occurs when trying to add a tag named "some"

What is the root cause of that problem?

We are getting are tags list from here and when it's empty we are returning an array but tags list is supposed to be an {}.When we have values in tags list it becomes an object that's why we don't see this error while editing tag

App/src/libs/PolicyUtils.ts

Lines 292 to 295 in cba1457

function getTagLists(policyTagList: OnyxEntry<PolicyTagLists>): Array<ValueOf<PolicyTagLists>> {
if (isEmptyObject(policyTagList)) {
return [];
}

And here when it's an empty array we are using an incorrect method to check
} else if (tags?.[tagName]) {

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

We can return {} here instead of an empty []

App/src/libs/PolicyUtils.ts

Lines 292 to 295 in cba1457

function getTagLists(policyTagList: OnyxEntry<PolicyTagLists>): Array<ValueOf<PolicyTagLists>> {
if (isEmptyObject(policyTagList)) {
return [];
}

We should also check for other places where we have this issue and fix it. We should also fix type errors that comes from this change.

What alternative solutions did you explore? (Optional)

@daledah
Copy link
Contributor

daledah commented Oct 1, 2024

Proposal

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

The system returns an error stating 'A tag with this name already exists' even though no tag named 'some' is present, which might indicate a system error.

What is the root cause of that problem?

In

} else if (tags?.[tagName]) {
errors.tagName = translate('workspace.tags.existingTagError');

We check if tags has property tagName to determine if the created tag already exist.

However, when we create a new workspace, the tags object is an array:

Screenshot 2024-10-02 at 03 43 24

it will only be updated to an object when a tag is created.

And some is a property of a Javascript's array object, which leads to tags?.[tagName] exists, make the error appears.
The same bug can happen with other array properties aswell, such as every, forEach, etc.

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

  1. We can fix this from the BE side so the returned Tag is always an object
  2. We can change the logic to handle array:

Update

} else if (tags?.[tagName]) {

to

else if (!Array.isArray(tags) && tags?.[tagName]) {

or

else if (Object.prototype.hasOwnProperty.call(tags, tagName)){

What alternative solutions did you explore? (Optional)

NA

@twisterdotcom
Copy link
Contributor

What a weird bug. Easy to recreate.
image

@twisterdotcom twisterdotcom added the External Added to denote the issue can be worked on by a contributor label Oct 2, 2024
@melvin-bot melvin-bot bot changed the title Tag - Error occurs when trying to add a tag named "some" [$250] Tag - Error occurs when trying to add a tag named "some" Oct 2, 2024
Copy link

melvin-bot bot commented Oct 2, 2024

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

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

melvin-bot bot commented Oct 2, 2024

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

@twisterdotcom twisterdotcom added Weekly KSv2 and removed Daily KSv2 labels Oct 2, 2024
@twisterdotcom twisterdotcom changed the title [$250] Tag - Error occurs when trying to add a tag named "some" [$125] Tag - Error occurs when trying to add a tag named "some" Oct 2, 2024
Copy link

melvin-bot bot commented Oct 2, 2024

Upwork job price has been updated to $125

@Nodebrute
Copy link
Contributor

Nodebrute commented Oct 2, 2024

I believe this may be a backend issue. The tags are supposed to be {} on the frontend, and we have set them correctly. However, when we create a workspace, the tags are being set to [] instead. I think the backend should ensure that the tags are set to {}.
Screenshot 2024-10-02 at 7 55 08 PM


tags: {},

cc: @allroundexperts @twisterdotcom

@sher999
Copy link

sher999 commented Oct 2, 2024

Proposal

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

Error occurs when trying to add a tag named "some"

What is the root cause of that problem?

checking on empty array is returning [Function some]

} else if (tags?.[tagName]) {

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

Check the lenght of the tags array if it is empty js will return false and skip the "else if" condition

 } else if (tags?.[tagName] && tags.length) { 

Checked on staging

ios native

Screen.Recording.2024-10-03.at.2.32.19.AM.mov

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Oct 2, 2024
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. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Overdue
Projects
None yet
Development

No branches or pull requests

6 participants