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-10-24] [$250] Search - Attachment from qa.guide loads infinitely when opened in Search #50006

Closed
6 tasks done
lanitochka17 opened this issue Oct 1, 2024 · 27 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 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
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to DM
  3. Send the following message. (The message is from [email protected]
    in #admins)
    Setup Guide GIF
  4. Go to Search > Chat
  5. Click on the message sent in Step 3

Expected Result:

The attachment will load without issue

Actual Result:

The attachment loads infinitely
This issue only happens to this specific attachment

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

Add any screenshot/video evidence

Bug6621041_1727782649186.20241001_192422.1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021841561644716083523
  • Upwork Job ID: 1841561644716083523
  • Last Price Increase: 2024-10-02
  • Automatic offers:
    • suneox | Reviewer | 104307339
    • shahinyan11 | Contributor | 104307340
Issue OwnerCurrent Issue Owner: @garrettmknight
@lanitochka17 lanitochka17 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 @garrettmknight (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
Copy link
Author

@garrettmknight 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
Copy link
Author

We think that this bug might be related to #wave-control

@garrettmknight garrettmknight 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 Search - Attachment from qa.guide loads infinitely when opened in Search [$250] Search - Attachment from qa.guide loads infinitely when opened in Search Oct 2, 2024
Copy link

melvin-bot bot commented Oct 2, 2024

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

@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 - @suneox (External)

@huult
Copy link
Contributor

huult commented Oct 3, 2024

Edited by proposal-police: This proposal was edited at 2024-10-03 13:17:41 UTC.

Proposal

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

Attachment from qa.guide loads infinitely when opened in Search

What is the root cause of that problem?

The reason for this ticket is that we are attempting to authenticate an attachment that is not an Expensify source, which prevents the attachment from loading and results in an infinite loading state.

In the case of this ticket, this GIF will use AttachmentView, and the isAuthTokenRequired prop will be set to true to render this GIF. AttachmentView is used because when the attachment modal is opened, the URL contains reportID set to -1, which prevents load the report. According to condition check #L542, AttachmentView should be rendered for this case. Additionally, this GIF is opened from Search, where isAuthTokenRequired is true, as indicated by condition #L49.
So, this GIF is not an Expensify source and will require authentication, as isAuthTokenRequired is set to true, as I mentioned. Therefore, this GIF can't load.

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

I suggest two options to fix this issue:

Option 1: We should update isAuthTokenRequired in cases where the source is not Expensify when opening the attachment modal from Search

// .src/components/SelectionList/ChatListItem.tsx#L43
-    const attachmentContextValue = {type: CONST.ATTACHMENT_TYPE.SEARCH};
+    const attachmentContextValue = {reportID: item.reportID, type: CONST.ATTACHMENT_TYPE.SEARCH};
// .src/components/AttachmentModal.tsx#L543
+  const [isImageAuthTokenRequired, setImageAuthTokenRequired] = useState(isAuthTokenRequired);

-                  {!shouldShowNotFoundPage &&
-                            (!isEmptyObject(report) && !isReceiptAttachment ? (
+                 {!shouldShowNotFoundPage &&
+                            (!isEmptyObject(report) && !isReceiptAttachment && type !== CONST.ATTACHMENT_TYPE.SEARCH ? (
                                <AttachmentCarousel
                                ....
// .src/components/Attachments/AttachmentView/index.tsx#L238
+    const compareImage = useCallback((attachment: Attachment) => attachment.source === source, [source]);
+    useEffect(() => {
+        if (type !== CONST.ATTACHMENT_TYPE.SEARCH) return;
+        const prReportAction = report?.parentReportActionID && parentReportActions ? parentReportActions[report?.parentReportActionID] : undefined;
+       const newAttachments: Attachment[] = extractAttachments(CONST.ATTACHMENT_TYPE.REPORT, {parentReportAction: prReportAction, reportActions: reportActions ?? undefined});

+       const newIndex = newAttachments.findIndex(compareImage);
+       const attachment = newAttachments.at(newIndex);

+      if (attachment?.isAuthTokenRequired !== undefined) {
+          setImageAuthTokenRequired(attachment?.isAuthTokenRequired);
+      }
+  }, [compareImage, parentReportActions, report?.parentReportActionID, reportActions, type]);

// .src/components/AttachmentModal.tsx#L291
<AttachmentViewImage
    ....
+    isAuthTokenRequired={type === CONST.ATTACHMENT_TYPE.SEARCH ? isImageAuthTokenRequired : isAuthTokenRequired}

Test branch for this option

Option 2: We use AttachmentCarousel when opening the attachment modal from Search to fix this issue because AttachmentCarousel checks isAuthTokenRequired for attachments inside. To use AttachmentCarousel, we need to update the code as shown below:

// .src/components/SelectionList/ChatListItem.tsx#L43
-    const attachmentContextValue = {type: CONST.ATTACHMENT_TYPE.SEARCH};
+    const attachmentContextValue = {reportID: item.reportID, type: CONST.ATTACHMENT_TYPE.SEARCH};
POC
Screen.Recording.2024-10-06.at.23.08.21.mov

@suneox
Copy link
Contributor

suneox commented Oct 3, 2024

We’re still awaiting a proposal on this issue. The RCA and solution provided by @huult proposal are not correct.

@shahinyan11
Copy link

@suneox @lanitochka17 I think the "Action performed:" steps and the provided video are not clear to users who are not familiar with Expensify. How to see #admins chat ? What steps should be done to have this message in somewhere to copy and test

@suneox
Copy link
Contributor

suneox commented Oct 3, 2024

@shahinyan11 At step 3 you have to copy content Send the following message ( ... ) included image

@shahinyan11
Copy link

shahinyan11 commented Oct 3, 2024

Edited by proposal-police: This proposal was edited at 2024-10-03 18:12:20 UTC.

Proposal

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

Search - Attachment from qa.guide loads infinitely when opened in Search

What is the root cause of that problem?

Here Is described in which cases the image need to have an authToken to be loaded. But the current case is not one of the described cases and we still add authToken to load the image.
It comes from here because we set isAuthTokenRequired based on ATTACHMENT_TYPE constant but I think the isAuthTokenRequired prop should be set based on this value.

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

  1. Add one more isAuthTokenRequired param in attachments route here obj

  2. Add isAttachmentOrReceipt as a last param in here

const route = ROUTES.ATTACHMENTS?.getRoute(reportID ?? '-1', type, source, accountID, isAttachmentOrReceipt);
  1. Update the isAuthTokenRequired prop value to route.params.isAuthTokenRequired

What alternative solutions did you explore? (Optional)

@shahinyan11
Copy link

@shahinyan11 At step 3 you have to copy content Send the following message ( ... ) included image

@suneox Thanks for your help.

@huult
Copy link
Contributor

huult commented Oct 4, 2024

Proposal Updated

  • Update the RCA.
  • Update the solution to resolve this issue.

@suneox, could you please check again? Thank you.

@suneox
Copy link
Contributor

suneox commented Oct 4, 2024

Thanks for all the proposals. I don’t think this issue is related to CORS blocking, since the images from both the chat and the search load the same resource url, just only the headers being different.

Screen.Recording.2024-10-04.at.18.09.12.mp4

@shahinyan11 Your solution doesn't work on my side

To resolve this issue, we can read the image from the cache to display it when opening the attachment. To retrieve the image from the cache, we update the parameters in the URL to match those of the previous image load.

@huult Could you please explain why updating the reportID parameter in the URL allows us to get a cached image, even though the image source (attachment?source) from URL does not change?

@shahinyan11
Copy link

@suneox Do you mean that my solution doesn't work at all or it's a workaround?

@suneox
Copy link
Contributor

suneox commented Oct 4, 2024

@suneox Do you mean that my solution doesn't work at all or it's a workaround?

@shahinyan11 Your solution doesn’t work as expected, the image still loads indefinitely

Screen.Recording.2024-10-04.at.22.21.04.mp4

@shahinyan11
Copy link

shahinyan11 commented Oct 5, 2024

Proposal

Updated. I have updated the RCA and solution. Could you check please and leave feedback

@melvin-bot melvin-bot bot added the Overdue label Oct 6, 2024
@huult
Copy link
Contributor

huult commented Oct 6, 2024

Proposal update

  • Update RCA

Hi @suneox , could you please check it again? thanks

@suneox
Copy link
Contributor

suneox commented Oct 6, 2024

Thanks for all the updates. I’ll reevaluate them within today.

@melvin-bot melvin-bot bot removed the Overdue label Oct 6, 2024
@suneox
Copy link
Contributor

suneox commented Oct 7, 2024

Although both solutions can resolve the issue but @shahinyan11’s solution is simpler. Instead of always setting isAuthTokenRequired in the attachment search case, we will retrieve the isAuthTokenRequired status from the previous thumbnail so we can proceed with @shahinyan11 solution.

🎀 👀 🎀 C+ reviewed

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

melvin-bot bot commented Oct 7, 2024

📣 @suneox 🎉 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 Oct 7, 2024

📣 @shahinyan11 🎉 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 Weekly KSv2 labels Oct 8, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 17, 2024
@melvin-bot melvin-bot bot changed the title [$250] Search - Attachment from qa.guide loads infinitely when opened in Search [HOLD for payment 2024-10-24] [$250] Search - Attachment from qa.guide loads infinitely when opened in Search Oct 17, 2024
Copy link

melvin-bot bot commented Oct 17, 2024

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 17, 2024
Copy link

melvin-bot bot commented Oct 17, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.49-2 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-10-24. 🎊

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

Copy link

melvin-bot bot commented Oct 17, 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:

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

@dylanexpensify dylanexpensify moved this to Hold for Payment in [#whatsnext] #expense Oct 18, 2024
@suneox
Copy link
Contributor

suneox commented Oct 22, 2024

Checklist

  • [@suneox] The PR that introduced the bug has been identified. Link to the PR: Implemented chat type in search #47690
  • [@suneox] 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
  • [@suneox] 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
  • [@suneox] Determine if we should create a regression test for this bug: N/A
  • [@suneox] 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. N/A

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Oct 23, 2024
@garrettmknight
Copy link
Contributor

All paid out!

@github-project-automation github-project-automation bot moved this from Hold for Payment to Done in [#whatsnext] #expense Oct 24, 2024
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Nov 5, 2024
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. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
Archived in project
Development

No branches or pull requests

6 participants