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-06-28] [$250] mWeb - Video - Download option is not working #43117

Closed
1 of 6 tasks
lanitochka17 opened this issue Jun 5, 2024 · 33 comments
Closed
1 of 6 tasks
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 Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Jun 5, 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: 1.4.79-3
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/4594355
Email or phone of affected tester (no customers): applausetester+vd_mweb060424@applause.expensifail.com
Issue reported by: Applause - Internal Team

Action Performed:

Pre-requisite: the user must be logged in

  1. Go to any chat
  2. Send a video
  3. Tap on the video preview
  4. Tap on the three dots menu and select "Download"

Expected Result:

The video should start downloading on the device

Actual Result:

Nothing happens after tapping on "Download" option

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

Bug6502136_1717538746108.Vnsc8116_1_.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~013079356c488afb74
  • Upwork Job ID: 1798664874044810128
  • Last Price Increase: 2024-06-06
  • Automatic offers:
    • ShridharGoel | Contributor | 102736117
    • bernhardoj | Contributor | 102779959
Issue OwnerCurrent Issue Owner: @twisterdotcom
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 5, 2024
Copy link

melvin-bot bot commented Jun 5, 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.

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

@lanitochka17
Copy link
Author

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

@bernhardoj
Copy link
Contributor

Proposal

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

Download video option doesn't work.

What is the root cause of that problem?

When we press the download option, it will take the video player ref source uri props and append an encryptedAuthToken to it.

const downloadAttachment = useCallback(() => {
if (videoPopoverMenuPlayerRef.current === null) {
return;
}
const {source} = videoPopoverMenuPlayerRef.current?.props ?? {};
if (typeof source === 'number' || !source) {
return;
}
const sourceURI = addEncryptedAuthTokenToURL(source.uri);
fileDownload(sourceURI);
}, [videoPopoverMenuPlayerRef]);

However, the video player ref source uri already has encryptedAuthToken appended to it. (if not a local file)

const [sourceURL] = useState(VideoUtils.addSkipTimeTagToURL(url.includes('blob:') || url.includes('file:///') ? url : addEncryptedAuthTokenToURL(url), 0.001));

source={{
// if video is loading and is offline, we want to change uri to "" to
// reset the video player after connection is back
uri: !isLoading || (isLoading && !isOffline) ? sourceURL : '',
}}

So, encryptedAuthToken is appended twice resulting in error.

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

Remove addEncryptedAuthTokenToURL from here.

const downloadAttachment = useCallback(() => {
if (videoPopoverMenuPlayerRef.current === null) {
return;
}
const {source} = videoPopoverMenuPlayerRef.current?.props ?? {};
if (typeof source === 'number' || !source) {
return;
}
const sourceURI = addEncryptedAuthTokenToURL(source.uri);
fileDownload(sourceURI);
}, [videoPopoverMenuPlayerRef]);

@ShridharGoel
Copy link
Contributor

ShridharGoel commented Jun 6, 2024

Proposal

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

mWeb - Video - Download option is not working.

What is the root cause of that problem?

In below code, we are adding encryptedAuthToken in the URL, but there's a possibility that it's already added:

const sourceURI = addEncryptedAuthTokenToURL(source.uri);

This is already being added from here as well:

const [sourceURL] = useState(VideoUtils.addSkipTimeTagToURL(url.includes('blob:') || url.includes('file:///') ? url : addEncryptedAuthTokenToURL(url), 0.001));

This leads to duplicate query params.

There are multiple other places as well where addEncryptedAuthTokenToURL is being called (all these are needed, but again there can be places where it gets added twice. Future logic changes can lead to same situation again.)

const sourceURLWithAuth = addEncryptedAuthTokenToURL(sourceURL ?? '');

file={isAuthTokenRequired ? addEncryptedAuthTokenToURL(previewSourceURL) : previewSourceURL}

source={{uri: isAuthTokenRequired ? addEncryptedAuthTokenToURL(previewSourceURL) : previewSourceURL}}

const encryptedSourceUrl = isAuthTokenRequired ? addEncryptedAuthTokenToURL(source as string) : (source as string);

Why does this issue happen only on mWeb?

Because on normal web, duplicate params are being handled gracefully (extra one is not there in the request). But on mWeb, the duplicate ones don't get removed which leads to an exception.

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

We should update the logic of addEncryptedAuthTokenToURL to only add the token if it doesn't exist:

export default function (url: string) {
    if (url.includes('encryptedAuthToken')) {
        return url
    }
    return `${url}?encryptedAuthToken=${encodeURIComponent(encryptedAuthToken)}`;
}

We can also change the name to addEncryptedAuthTokenToURLIfNeeded.ts or something similar.

This will also make it future-proof, even if the auth token method gets called multiple times, it would only be added once.

@twisterdotcom twisterdotcom added the External Added to denote the issue can be worked on by a contributor label Jun 6, 2024
@melvin-bot melvin-bot bot changed the title mWeb - Video - Download option is not working [$250] mWeb - Video - Download option is not working Jun 6, 2024
Copy link

melvin-bot bot commented Jun 6, 2024

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

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

melvin-bot bot commented Jun 6, 2024

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

@jayeshmangwani
Copy link
Contributor

We can remove the addEncryptedAuthTokenToURL from downloadAttachment function, tested with few Download scenarios and it looks that we are already passing the auth token to every source files, @ShridharGoel do you have any scenario where you have found if we are not passing the addEncryptedAuthTokenToURL to the source ? If yes then I would agree with the adding the check of the encryptedAuthToken in the function.

But It looks that we already passing the EncryptedAuthToken already then @bernhardoj 's Proposal of removing the addEncryptedAuthTokenToURL from downloadAttachment function Looks good to me

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Jun 7, 2024

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

Copy link

melvin-bot bot commented Jun 10, 2024

@twisterdotcom, @jayeshmangwani, @grgia Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added the Overdue label Jun 10, 2024
@jayeshmangwani
Copy link
Contributor

Not Overdue!
@grgia Whats your thought on the above Proposal ?

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jun 10, 2024
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 14, 2024
Copy link

melvin-bot bot commented Jun 14, 2024

📣 @ShridharGoel 🎉 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 removed the Overdue label Jun 14, 2024
@bernhardoj
Copy link
Contributor

@grgia I think @jayeshmangwani meant to approve my proposal

Copy link

melvin-bot bot commented Jun 17, 2024

@twisterdotcom, @jayeshmangwani, @ShridharGoel, @grgia Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added the Overdue label Jun 17, 2024
@grgia
Copy link
Contributor

grgia commented Jun 18, 2024

@jayeshmangwani could you highlight the chosen proposal, I was under the impression you had said @ShridharGoel's proposal was fine. When you choose a proposal, could you include only the chosen proposal with the C+ reviewed comment?

@melvin-bot melvin-bot bot removed the Overdue label Jun 18, 2024
@jayeshmangwani
Copy link
Contributor

When you choose a proposal, could you include only the chosen proposal with the C+ reviewed comment?

I will keep this in mind for future reference. I should have split the comment. 🤦

@grgia
Copy link
Contributor

grgia commented Jun 18, 2024

@jayeshmangwani could you address #43117 (comment) ?

Or would you suggest we move forward with @bernhardoj's proposal.

Thanks for your understanding everyone

@jayeshmangwani
Copy link
Contributor

When I was testing the downloadAttachment function with a few scenarios, we were passing the addEncryptedAuthTokenToURL to the source files every time. That's why I was considering going with the @bernhardoj 's proposal. I asked the same question to @ShridharGoel two weeks ago to see if they could find any scenario where we are not passing the encryptedAuthToken.

Or would you suggest we move forward with @bernhardoj's proposal.

@grgia If there is no need to add the addEncryptedAuthTokenToURL for any file, then we can safely remove it as per @bernhardoj's proposal.

@grgia
Copy link
Contributor

grgia commented Jun 18, 2024

@jayeshmangwani #3597
It seems like we should be using addEncryptedAuthTokenToURL for all downloaded attachments no?

@jayeshmangwani
Copy link
Contributor

It seems like we should be using addEncryptedAuthTokenToURL for all downloaded attachments no?

Yes If isAuthTokenRequired is true then we need to append the encryptedAuthToken to the source url, but the thing here in this issue is we are appending the encryptedAuthToken twice, we already added EncryptedAuthTokenToURL to the sourceURL here:

const [sourceURL] = useState(VideoUtils.addSkipTimeTagToURL(url.includes('blob:') || url.includes('file:///') ? url : addEncryptedAuthTokenToURL(url), 0.001));

Then, we are passing the sourceURL to Video source.uri

source={{
// if video is loading and is offline, we want to change uri to "" to
// reset the video player after connection is back
uri: !isLoading || (isLoading && !isOffline) ? sourceURL : '',
}}

And here we are again appending the encryptedAuthToken to the source.uri

const sourceURI = addEncryptedAuthTokenToURL(source.uri);

@grgia
Copy link
Contributor

grgia commented Jun 18, 2024

Gotcha, that makes much more sense thank you @jayeshmangwani

@grgia grgia assigned bernhardoj and unassigned ShridharGoel Jun 18, 2024
Copy link

melvin-bot bot commented Jun 18, 2024

📣 @bernhardoj 🎉 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 📖

@grgia
Copy link
Contributor

grgia commented Jun 18, 2024

Going to go with @bernhardoj's proposal. @ShridharGoel let me know if you need help finding an issue to work on!

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Jun 19, 2024
@bernhardoj
Copy link
Contributor

PR is ready

cc: @jayeshmangwani

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jun 21, 2024
@melvin-bot melvin-bot bot changed the title [$250] mWeb - Video - Download option is not working [HOLD for payment 2024-06-28] [$250] mWeb - Video - Download option is not working Jun 21, 2024
Copy link

melvin-bot bot commented Jun 21, 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 Jun 21, 2024
Copy link

melvin-bot bot commented Jun 21, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.0-9 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-06-28. 🎊

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

Copy link

melvin-bot bot commented Jun 21, 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:

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

@jayeshmangwani
Copy link
Contributor

  • [@jayeshmangwani] The PR that introduced the bug has been identified. Link to the PR: Incorrect video downloaded #40647 #41054
  • [@jayeshmangwani] 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: Incorrect video downloaded #40647 #41054 (comment)
  • [@jayeshmangwani] 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: Issue can be found when testing; no need to create a discussion for this.
  • [@jayeshmangwani] Determine if we should create a regression test for this bug. Yes
  • [@jayeshmangwani] 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.

Regression Test Proposal

  1. Send a video to any chat
  2. Open the video preview
  3. Press the three-dot button
  4. Press the download option
  5. Verify the video is downloaded

Do we agree 👍 or 👎

@twisterdotcom
Copy link
Contributor

Payment Summary:

@jayeshmangwani
Copy link
Contributor

Requested $250 on NewDot.

@JmillsExpensify
Copy link

$250 approved for @jayeshmangwani

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 Weekly KSv2
Projects
No open projects
Archived in project
Development

No branches or pull requests

7 participants