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-05] [$125] Chat - Onyx and DOMException console errors appear when sending an image in a DM #44603

Closed
1 of 6 tasks
m-natarajan opened this issue Jun 28, 2024 · 43 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 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@m-natarajan
Copy link

m-natarajan commented Jun 28, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Issue found when validating #42592
Version Number: 9.0.3-1
Reproducible in staging?: y
Reproducible in production?: n
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: Applause internal team
Slack conversation:

Action Performed:

Preconditions: Be a workspace member as a new Gmail account.

  1. Navigate to https://staging.new.expensify.com/
  2. Log in as the member account
  3. Click on FAB - Start chat
  4. Select any existing Gmail account
  5. Open Chrome console
  6. Send an image attachment in the chat

Expected Result:

There shouldn't be any console errors when sending an image.

Actual Result:

"Onyx" and "Uncaught (in promise) DOMException" console errors appear when sending an image in a DM. The "Onyx" error only appears when the user is part of a workspace.

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

Bug6527021_1719554233249!staging.new.expensify.com-1719553282882.txt

Bug6527021_1719554233211.bandicam_2024-06-28_07-40-50-491.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~010b91b6cb691a5c72
  • Upwork Job ID: 1806791265391666720
  • Last Price Increase: 2024-07-05
  • Automatic offers:
    • hoangzinh | Reviewer | 103033509
    • nkdengineer | Contributor | 103033510
Issue OwnerCurrent Issue Owner: @dylanexpensify
@m-natarajan m-natarajan added DeployBlockerCash This issue or pull request should block deployment Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. DeployBlocker Indicates it should block deploying the API labels Jun 28, 2024
Copy link

melvin-bot bot commented Jun 28, 2024

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

Copy link

melvin-bot bot commented Jun 28, 2024

Triggered auto assignment to @iwiznia (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels Jun 28, 2024
Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@m-natarajan
Copy link
Author

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

@m-natarajan
Copy link
Author

We think that this bug might be related to #vip-vsb

@dylanexpensify
Copy link
Contributor

@iwiznia confirmed reproducible

@iwiznia
Copy link
Contributor

iwiznia commented Jun 28, 2024

In dev I have a billion errors, but not this one.... but also images are not working properly not sure why.

@iwiznia
Copy link
Contributor

iwiznia commented Jun 28, 2024

I kept struggling with my dev env and still could not make images work there. Will look more on monday

@mountiny mountiny added the External Added to denote the issue can be worked on by a contributor label Jun 28, 2024
@melvin-bot melvin-bot bot changed the title Chat - Onyx and DOMException console errors appear when sending an image in a DM [$250] Chat - Onyx and DOMException console errors appear when sending an image in a DM Jun 28, 2024
Copy link

melvin-bot bot commented Jun 28, 2024

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

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

melvin-bot bot commented Jun 28, 2024

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

@mountiny
Copy link
Contributor

@kavimuru @m-natarajan @izarutskaya I have tested and the image got sent. I think if it's just a console error without affecting the user, we do not have to block the deploy on it

@mountiny mountiny changed the title [$250] Chat - Onyx and DOMException console errors appear when sending an image in a DM [$125] Chat - Onyx and DOMException console errors appear when sending an image in a DM Jun 28, 2024
Copy link

melvin-bot bot commented Jun 28, 2024

Upwork job price has been updated to $125

@nkdengineer
Copy link
Contributor

nkdengineer commented Jun 29, 2024

Proposal

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

"Onyx" and "Uncaught (in promise) DOMException" console errors appear when sending an image in a DM. The "Onyx" error only appears when the user is part of a workspace.

What is the root cause of that problem?

When saving attachmentInfo to Onyx when sending attachment, the file is being saved to Onyx as is

const attachmentInfo = file ?? {};

However the file selected from the image picker is not a purely JSON-compatible object, it contains functions too (eg. function arrayBuffer as in the error log).

When we attempt to save such function to Onyx, it cannot be serialized and will throw error.

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

Before using the saving the file data to Onyx here

const attachmentInfo = file ?? {};
, we need to sanitize it to a JSON-compatible object, the functions are not needed so can be stripped.

const attachmentInfo = file ? {
      name: file?.name,
      source: file?.source,
      uri: file?.uri,
      height: file?.height,
      size: file?.size,
      type: file?.type,
      width: file?.width,
  } : {};

Actually we don't need all the fields of the attachmentInfo because we typically only check the field's existence like in

return reportAction?.isAttachment ?? !!reportAction?.attachmentInfo ?? false;

So we can replace attachmentInfo with a boolean hasAttachmentInfo which indicates attachmentInfo's existence

The same needs to be done for the updateParams here we need to map the JSON-compatible fields like above, or use the sanitizeObject method in the alternative solution. Also same for any location (if any) that could saves objects with functions to Onyx.

What alternative solutions did you explore? (Optional)

Alternate solution 1:

So we can replace attachmentInfo with a boolean hasAttachmentInfo which indicates attachmentInfo's existence

Building on top of the above, a clearer naming could be isAttachmentOnly and isAttachmentWithText, we can handle the naming of variables in PR phase.

Alternate solution 2:
We can write and use a method sanitizeObject that will iterate through all object propoperties and remove all functions or other non-serializable values, leaving only primitive values that can be serialized.

Example implementation pseudo code

function sanitizeObject(obj) {
  return JSON.parse(JSON.stringify(obj, (key, value) => {
    if (value === undefined || typeof value === 'function') {
      return undefined;
    }
    return value;
  }));
}

Manual iteration should also work well.

We can even do this sanitization inside react-native-onyx, before saving anything to local storage, but I prefer being explicit as in the main solution.

@nkdengineer
Copy link
Contributor

Proposal updated with 2nd solution

@hoangzinh
Copy link
Contributor

@nkdengineer thanks for proposing. Are you able to find the offending PR? Moreover, when I test your solution in Web, it raises another error:

Screenshot 2024-06-29 at 11 13 45

@hoangzinh
Copy link
Contributor

@nkdengineer can you put into an alternative solution 1, alternative solution 2 so it's clearer to select?

@nkdengineer
Copy link
Contributor

@hoangzinh Sure, I've done that

@hoangzinh
Copy link
Contributor

@nkdengineer's alternative solution 1 looks good to me #44603 (comment)

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Jul 8, 2024

Current assignee @iwiznia is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@iwiznia
Copy link
Contributor

iwiznia commented Jul 8, 2024

Looks good to me too

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

melvin-bot bot commented Jul 8, 2024

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

Offer link
Upwork job

Copy link

melvin-bot bot commented Jul 8, 2024

📣 @nkdengineer 🎉 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 Weekly KSv2 and removed Daily KSv2 labels Jul 9, 2024
@nkdengineer
Copy link
Contributor

@hoangzinh The PR is here.

@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 29, 2024
@melvin-bot melvin-bot bot changed the title [$125] Chat - Onyx and DOMException console errors appear when sending an image in a DM [HOLD for payment 2024-08-05] [$125] Chat - Onyx and DOMException console errors appear when sending an image in a DM Jul 29, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 29, 2024
Copy link

melvin-bot bot commented Jul 29, 2024

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

Copy link

melvin-bot bot commented Jul 29, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.13-4 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-05. 🎊

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

Copy link

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

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

@dylanexpensify
Copy link
Contributor

Payment summary:

Please apply/request!

@dylanexpensify
Copy link
Contributor

@nkdengineer please accept offer when you can!

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

@dylanexpensify Thanks for the offer, I accepted it 👍

@dylanexpensify
Copy link
Contributor

Nice - paying now!

@dylanexpensify
Copy link
Contributor

Done!

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 Engineering External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

7 participants