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
[HOLD for payment 2024-07-22] [$250] Tag - App crashes when saving 0 as custom tag name #43773
Version Number: 1.4.83-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:https://expensify.testrail.io/index.php?/tests/view/4631162 Issue reported by: Applause - Internal Team
Action Performed:
Go to staging.new.expensify.com
Go to workspace settings > Tags
Click Settings > Custom tag name
Enter 0 and save it
Expected Result:
App will not crash
Actual Result:
App crashes when saving 0 as custom tag name
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
@slafortune 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
The code gets the values of the object and then extracts the tags property from them. TagName has the tags property, but errors doesn't have the tags property because it's not a tag.
What changes do you think we should make in order to solve the problem?
Please re-state the problem that we are trying to solve in this issue.
Naming or renaming policy tag list setting with name as '0' crashes the app with failure.
What is the root cause of that problem?
Error in console. src\pages\workspace\tags\WorkspaceTagsSettingsPage.tsx
Uncaught TypeError: Cannot convert undefined or null to object
at Function.values (<anonymous>)
at eval (WorkspaceTagsSettingsPage.tsx:35:1)
at Array.flatMap (<anonymous>)
at WorkspaceTagsSettingsPage (WorkspaceTagsSettingsPage.tsx:33:138)
at renderWithHooks (react-dom.development.js:16175:18)
at updateFunctionComponent (react-dom.development.js:20382:20)
at beginWork (react-dom.development.js:22425:16)
at HTMLUnknownElement.callCallback (react-dom.development.js:4161:14)
at Object.invokeGuardedCallbackDev (react-dom.development.js:4210:16)
at invokeGuardedCallback (react-dom.development.js:4274:31)
App calls backend API RenamePolicyTaglist with valid oldName property and newName property as '0'. Backend responds back with error.
While processing the response after converting policyTags to flatMap, which expects tag names inside it (instead of generic error that comes back from API), the code fails to fetch tags.
Code expects property tags inside the response. This works fine in case of a successful response as there is tags property inside tagsListData . But in case of errors, though response code is HTTP 200, tags property is completely missing.
As the code always assumes the presence of tags property, this fails in case of errors.
What changes do you think we should make in order to solve the problem?
Assuming that we always get a successful response is incorrect. Frontend code must be able to handle error responses in a graceful way.
Suggest following approaches for this
Check that tags property is not undefined. If that is missing, fallback for error response and fetch and display appropriate error as a red error text under tagList setting name field, based on the error message returned from backend. Display options for error need UI/UX input.
Alternatively, accept only valid tag names from frontend using regex. Also as the field is pre-populated with value Tag, do not allow changing the pre-populated text, instead forcefully accept only appending to this value. Need product input on this.
What are possible valid tag names and invalid tag names? Why is '0' an invalid tag name? Would like to understand this requirement to help in choosing the best option.
What alternative solutions did you explore? (Optional)
Backend to return tags as empty property in API response and add error as a different property, rather than replacing tags property.
changed the title [-]Tag - App crashes when saving 0 as custom tag name[/-][+][$250] Tag - App crashes when saving 0 as custom tag name[/+]on Jun 17, 2024
changed the title [-][$250] Tag - App crashes when saving 0 as custom tag name[/-][+][HOLD for payment 2024-07-22] [$250] Tag - App crashes when saving 0 as custom tag name[/+]on Jul 15, 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:
[@ZhenjaHorbach] The PR that introduced the bug has been identified. Link to the PR:
Crash is related to this PR where we try to get tags property from errors object
But the main root cause where we pass errors separately from tag objects is related to this PR
[@ZhenjaHorbach] 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:
[@ZhenjaHorbach] 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
[@ZhenjaHorbach] Determine if we should create a regression test for this bug.
I'm not sure we need a test for this bug
Because it's much harder to reproduce now
Since 0 is now a valid value
Plus I can't think of a stable way how we can throw an error for testing
[@ZhenjaHorbach] 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.
But just in case I added test steps
Regression Test Proposal
Go to workspace tags page
Press Settings
Press the tag name
Rename the tag to invalid value
When it fails, verify the tag name reverts to the previous name
Activity
melvin-bot commentedon Jun 14, 2024
Triggered auto assignment to @slafortune (
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 Jun 14, 2024
@slafortune 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 Jun 14, 2024
We think that this bug might be related to #wave-collect - Release 1
bernhardoj commentedon Jun 14, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
App crash when trying to save tag name as 0.
What is the root cause of that problem?
When we save the tag name as 0, the BE responds with an invalid error. If it fails, we set an errors object to the policy tag list collection.
App/src/libs/actions/Policy/Tag.ts
Lines 557 to 563 in f0b6355
So, it becomes:
Then, it crashes in this line of code
App/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx
Line 36 in f0b6355
The code gets the values of the object and then extracts the
tagsproperty from them.TagNamehas thetagsproperty, buterrorsdoesn't have thetagsproperty because it's not a tag.What changes do you think we should make in order to solve the problem?
If we see the offline with feedback here,
App/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx
Lines 76 to 78 in f0b6355
we can see that the component expects the error property to be added inside the tag object, just like what we did with the pendingAction.
App/src/libs/actions/Policy/Tag.ts
Line 538 in f0b6355
So, we need to update the failure data to
Last thing we need to do is to clear the error when pressing the offline with feedback close (X) button.
kpadmanabhan commentedon Jun 14, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Naming or renaming policy tag list setting with name as '0' crashes the app with failure.
What is the root cause of that problem?
Error in console.
src\pages\workspace\tags\WorkspaceTagsSettingsPage.tsxApp calls backend API
RenamePolicyTaglistwith validoldNameproperty andnewNameproperty as '0'. Backend responds back with error.While processing the response after converting
policyTagsto flatMap, which expects tag names inside it (instead of generic error that comes back from API), the code fails to fetch tags.Code expects property
tagsinside the response. This works fine in case of a successful response as there istagsproperty insidetagsListData. But in case of errors, though response code is HTTP 200,tagsproperty is completely missing.As the code always assumes the presence of
tagsproperty, this fails in case of errors.What changes do you think we should make in order to solve the problem?
Assuming that we always get a successful response is incorrect. Frontend code must be able to handle error responses in a graceful way.
Suggest following approaches for this
tagsproperty is notundefined. If that is missing, fallback for error response and fetch and display appropriate error as a red error text under tagList setting name field, based on the error message returned from backend. Display options for error need UI/UX input.What alternative solutions did you explore? (Optional)
Backend to return
tagsas empty property in API response and adderroras a different property, rather than replacingtagsproperty.[-]Tag - App crashes when saving 0 as custom tag name[/-][+][$250] Tag - App crashes when saving 0 as custom tag name[/+]melvin-bot commentedon Jun 17, 2024
Job added to Upwork: https://www.upwork.com/jobs/~01aa311cffaf18adc9
26 remaining items
bernhardoj commentedon Jun 25, 2024
PR is ready
cc: @ZhenjaHorbach
danieldoglas commentedon Jul 8, 2024
Backend changes implemented, waiting to be merged/deployed
danieldoglas commentedon Jul 12, 2024
This is kind of done?
@slafortune not sure why it didn't create the comments, the app part it's already in production!
slafortune commentedon Jul 12, 2024
Thanks for the heads up @danieldoglas - so are we just in the 7 day holding period for regressions? Which would be 7/17
[-][$250] Tag - App crashes when saving 0 as custom tag name[/-][+][HOLD for payment 2024-07-22] [$250] Tag - App crashes when saving 0 as custom tag name[/+]ZhenjaHorbach commentedon Jul 17, 2024
Crash is related to this PR where we try to get
tagsproperty fromerrorsobjectBut the main root cause where we pass
errorsseparately from tag objects is related to this PRhttps://github.com/Expensify/App/pull/42004/files#r1681339465
https://github.com/Expensify/App/pull/37734/files#r1681340313
NA
I'm not sure we need a test for this bug
Because it's much harder to reproduce now
Since 0 is now a valid value
Plus I can't think of a stable way how we can throw an error for testing
But just in case I added test steps
Regression Test Proposal
Do we agree 👍 or 👎 ?
bernhardoj commentedon Jul 17, 2024
@slafortune yes, the payment should be due today (7/17). I have requested the payment in ND.
slafortune commentedon Jul 18, 2024
@ZhenjaHorbach - C+ Role - has been paid $250 via UpWorks
@bernhardoj - Contributor Role - is due $250 via NewDot
JmillsExpensify commentedon Jul 19, 2024
$250 approved for @bernhardoj