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

[HOLD for payment 2024-08-07] [$250] Group - Invalid group chat name entered after group creation shows error. #45586

Closed
2 of 6 tasks
izarutskaya opened this issue Jul 17, 2024 · 21 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@izarutskaya
Copy link

izarutskaya commented Jul 17, 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: 9.0.8
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/4730508
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal team

Action Performed:

  1. Go to https://staging.new.expensify.com/home
  2. Tap fab - start chat
  3. Select " Add to group" next to a user
  4. Tap next
  5. Tap group name
  6. Remove the text and paste invalid group name - adoadoadoajdoajdoadoajdoajadoadoadoajdoajdoadoajdoajadoadoadoajdoajdoadoajdoajadoadoadoajdoajdoadoaỏ
  7. Tap start group
  8. Tap header
  9. Tap group name
  10. Remove the group name and replace with any text and save it
  11. Again tap group name
  12. Paste - invalid group name - adoadoadoajdoajdoadoajdoajadoadoadoajdoajdoadoajdoajadoadoadoajdoajdoadoajdoajadoadoadoajdoajdoadoaỏ
  13. Tap save

Expected Result:

Invalid group chat name entered while creating group or after group creation must behave in the same way.

Actual Result:

Invalid group chat name entered while creating group not showing error but entered after group creation shows 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

Bug6544708_1721196432232.inva.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0114cd4bde59962aa8
  • Upwork Job ID: 1815530149727742960
  • Last Price Increase: 2024-07-22
  • Automatic offers:
    • dominictb | Contributor | 103256417
Issue OwnerCurrent Issue Owner: @alexpensify
@izarutskaya izarutskaya added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 17, 2024
Copy link

melvin-bot bot commented Jul 17, 2024

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

@izarutskaya
Copy link
Author

We think this issue might be related to the #vip-vsb.

@Krishna2323
Copy link
Contributor

Proposal

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

Group - Invalid group chat name entered after group creation shows error.

What is the root cause of that problem?

No validation for invalid group name is added on the frontend and the backend only returns error when group name is updated.

const validate = useCallback(
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.NEW_CHAT_NAME_FORM>): Errors => {
const errors: Errors = {};
if (!ValidationUtils.isValidReportName(values[INPUT_IDS.NEW_CHAT_NAME] ?? '')) {
errors.newChatName = translate('common.error.characterLimit', {limit: CONST.REPORT_NAME_LIMIT});
}
return errors;
},
[translate],
);

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

We should add validation check on the frontend also, for validation we should add the same regex/check used in the backend.

What alternative solutions did you explore? (Optional)

@gijoe0295
Copy link
Contributor

gijoe0295 commented Jul 17, 2024

Proposal

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

Invalid group chat name entered while creating group from the BE.

What is the root cause of that problem?

We simply validated the name length by name.length:

return name.trim().length <= CONST.REPORT_NAME_LIMIT;

However, in the test string, there was an Unicode character or which would be counted differently instead of just 1 (reference here). That's why the validation passed in the FE but failed in the BE.

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

We need to match the length validation with the BE by using getCommentLength:

App/src/libs/ReportUtils.ts

Lines 5704 to 5709 in 88f9419

/**
* Performs the markdown conversion, and replaces code points > 127 with C escape sequences
* Used for compatibility with the backend auth validator for AddComment, and to account for MD in comments
* @returns The comment's total length as seen from the backend
*/
function getCommentLength(textComment: string, parsingDetails?: ParsingDetails): number {

@melvin-bot melvin-bot bot added the Overdue label Jul 19, 2024
@alexpensify
Copy link
Contributor

Other GHs have been a priority, I'll review soon

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jul 19, 2024
@alexpensify alexpensify added the External Added to denote the issue can be worked on by a contributor label Jul 22, 2024
Copy link

melvin-bot bot commented Jul 22, 2024

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

@melvin-bot melvin-bot bot changed the title Group - Invalid group chat name entered after group creation shows error. [$250] Group - Invalid group chat name entered after group creation shows error. Jul 22, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 22, 2024
Copy link

melvin-bot bot commented Jul 22, 2024

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

@alexpensify
Copy link
Contributor

alexpensify commented Jul 22, 2024

@sobitneupane - can you review if one of these proposals will fix this problem? Thanks!

@dominictb
Copy link
Contributor

dominictb commented Jul 23, 2024

Proposal

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

  • Invalid group chat name entered while creating group not showing error but entered after group creation shows error.

What is the root cause of that problem?

  • Refer to comment, in BE side, we check if the report name is valid or not based on:
       strlen(reportName) <= 100

with strlen function from PHP. In PHP, strlen counts bytes. With the text mentioned in OP, the strlen() return 102.

  • In FE, we check if the report name is valid or not based on:

    return name.trim().length <= CONST.REPORT_NAME_LIMIT;

    in here, JavaScript string.length counts characters. With the text mentioned in OP, string.length return 100.

  • That leads to inconsistency when validating between FE and BE.

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

function isValidReportName(name: string) {
    return new Blob([name.trim()]).size <= CONST.REPORT_NAME_LIMIT;
}
  • In above, we count bytes instead of character to sync with BE.

What alternative solutions did you explore? (Optional)

Beside the main change above, we can:

  • Remove the maxLength value in InputComponent because we already have the validate function to handle if user exceeds max length.

  • We should handle the similar related inconsistency issue.

@sobitneupane
Copy link
Contributor

Thanks for the proposal everyone.

Proposal from @dominictb looks good to me. The change proposed will ensure the FE validation. We might want to validate the groupChatName in BE as well during group creation. Looks like the validation is only done when groupChatName is updated.

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Jul 24, 2024

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

@NikkiWines
Copy link
Contributor

agreed that @dominictb's proposal looks good 👍

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 24, 2024
Copy link

melvin-bot bot commented Jul 24, 2024

📣 @dominictb 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot melvin-bot bot added Reviewing Has a PR in review and removed Daily KSv2 labels Jul 25, 2024
@melvin-bot melvin-bot bot added the Weekly KSv2 label Jul 25, 2024
@alexpensify
Copy link
Contributor

Awesome, this PR is moving along, and we are waiting for it to go to production.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jul 31, 2024
@melvin-bot melvin-bot bot changed the title [$250] Group - Invalid group chat name entered after group creation shows error. [HOLD for payment 2024-08-07] [$250] Group - Invalid group chat name entered after group creation shows error. Jul 31, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 31, 2024
Copy link

melvin-bot bot commented Jul 31, 2024

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

Copy link

melvin-bot bot commented Jul 31, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.14-6 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 2024-08-07. 🎊

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

Copy link

melvin-bot bot commented Jul 31, 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:

  • [@sobitneupane] The PR that introduced the bug has been identified. Link to the PR:
  • [@sobitneupane] 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:
  • [@sobitneupane] 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:
  • [@sobitneupane] Determine if we should create a regression test for this bug.
  • [@sobitneupane] 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.
  • [@alexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@alexpensify
Copy link
Contributor

Noted that the payment date is on August 7

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Aug 7, 2024
@alexpensify
Copy link
Contributor

alexpensify commented Aug 7, 2024

Payouts due: August 7, 2024

  • Contributor: $250 @dominictb - I completed the process in Upwork
  • Contributor+: $250 @sobitneupane - Please submit a request in Chat

Upwork job is here.

@alexpensify
Copy link
Contributor

Closing - the upwork process is complete

@garrettmknight
Copy link
Contributor

$250 approved for @sobitneupane

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

8 participants