-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[AWAITING CHECKLIST][Due for payment 2025-02-18] [$250] Web - Attachments - Incorrect file format is downloaded when downloading video from preview #55541
Comments
Triggered auto assignment to @JmillsExpensify ( |
ProposalPlease re-state the problem that we are trying to solve in this issue.Incorrect file format is downloaded when downloading video from preview What is the root cause of that problem?
What changes do you think we should make in order to solve the problem?
Refactored function**
* Extract the original filename from the HTML based on tag type.
*/
const getOriginalFileName = (html: string, isImageTag: boolean): string | null => {
const ORIGINAL_FILENAME_REGEX = isImageTag ? new RegExp(`${CONST.ATTACHMENT_ORIGINAL_FILENAME_ATTRIBUTE}*=*"(.+?)"`, 'i') : new RegExp('<(?:a|video)[^>]*>([^<]+)</(?:a|video)>', 'i');
return html.match(ORIGINAL_FILENAME_REGEX)?.[1] ?? null;
};
/**
* Extract the thumbnail URL, source URL from the HTML.
*/
const getAttachmentDetails: GetAttachmentDetails = (html) => {
if (!html) {
return {
previewSourceURL: null,
sourceURL: null,
originalFileName: null,
};
}
// Files can be rendered either as anchor tag or as an image
const IS_IMAGE_TAG = /<img([\w\W]+?)\/>/i.test(html);
const PREVIEW_SOURCE_REGEX = new RegExp(`${CONST.ATTACHMENT_PREVIEW_ATTRIBUTE}*=*"(.+?)"`, 'i');
const SOURCE_REGEX = new RegExp(`${CONST.ATTACHMENT_SOURCE_ATTRIBUTE}*=*"(.+?)"`, 'i');
// Files created/uploaded/hosted by App should resolve from API ROOT. Other URLs aren't modified
const sourceURL = tryResolveUrlFromApiRoot(html.match(SOURCE_REGEX)?.[1] ?? '');
const imageURL = IS_IMAGE_TAG ? tryResolveUrlFromApiRoot(html.match(PREVIEW_SOURCE_REGEX)?.[1] ?? '') : null;
const previewSourceURL = IS_IMAGE_TAG ? imageURL : sourceURL;
const originalFileName = getOriginalFileName(html, IS_IMAGE_TAG);
return {
previewSourceURL,
sourceURL,
originalFileName,
};
};
Get the file name and pass it to the fileDownload: const filename = getOriginalFileName(source.uri, false);
fileDownload(source.uri, filename); What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?NA What alternative solutions did you explore? (Optional)NA new.video.jan45.mov |
Job added to Upwork: https://www.upwork.com/jobs/~021881748185068126898 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @sobitneupane ( |
ProposalPlease re-state the problem that we are trying to solve in this issue.The downloaded video doesn't have a correct format. What is the root cause of that problem?When we add a new video, it's still uploading. The video we see is a local file. When we press download, it will download based on the local file uri (blob://...).
![]() We already have a logic to hide the Download button if it's a local file. App/src/components/VideoPlayerContexts/VideoPopoverMenuContext.tsx Lines 45 to 51 in 0190b0a
But the
What changes do you think we should make in order to solve the problem?Instead of using the currently playing URL, we should use the URL of the video that we open the popover menu. We will set the URL when opening the popover, just like we did with the playback rate. App/src/components/VideoPlayer/BaseVideoPlayer.tsx Lines 155 to 165 in 0190b0a
We need to add the new source state here and update the App/src/components/VideoPlayerContexts/VideoPopoverMenuContext.tsx Lines 15 to 20 in 0190b0a
App/src/components/VideoPlayerContexts/VideoPopoverMenuContext.tsx Lines 35 to 39 in 0190b0a
Then, when downloading the file, we use the source state and add encrypted auth token to it.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?N/A |
ProposalPlease re-state the problem that we are trying to solve in this issue.Web - Attachments - Incorrect file format is downloaded when downloading video from preview What is the root cause of that problem?When I added a This issue occurs because we used What changes do you think we should make in order to solve the problem?
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?None What alternative solutions did you explore? (Optional)None |
ProposalPlease re-state the problem that we are trying to solve in this issue.Incorrect file format is downloaded when downloading video from preview. This happens only when the user that has submitted the video did not reload the chat yet. What is the root cause of that problem?The VideoPlayer (more precisely VideoPopoverMenuContext) is missing the video extension in the video file name and thus the downloaded file does not contain the file format extension What changes do you think we should make in order to solve the problem?We should propagate the video file format extension from the original file name to the video player download feature using the PlaybackContext. We retrieve the extension by adding the following code in src/components/HTMLEngineProvider/HTMLRenderers/VideoRenderer.tsx
The fileName passed below will then have the file format extension* App/src/components/HTMLEngineProvider/HTMLRenderers/VideoRenderer.tsx Lines 36 to 45 in 4ccb6ec
The extension is then retrieved and passed to VideoPlayer here
and then added to PlaybackContext
and setted by BaseVideoPlayer as
the extension is then retrieved by VideoPopoverMenuContext through its call to PlaybackContext from
into
and then passed to its downloadAttachment function if necessary by changing the following line
into
RESULT2025-01-23.16-21-15.mp4What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?None What alternative solutions did you explore? (Optional)None |
@JmillsExpensify, @sobitneupane Huh... This is 4 days overdue. Who can take care of this? |
Thanks for the proposal, everyone. Proposal from @hellohublot looks good to me. 🎀 👀 🎀 C+ reviewed |
Triggered auto assignment to @Gonals, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
📣 @hellohublot 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
❤️ Thank you very much! However, after further investigation, I found that syncing the value of ux.mp4Maybe this proposal would be more appropriate: #55541 (comment). Waiting for CPLUS to determine the better proposal moving forward 🙏 |
Thanks @hellohublot The root cause of the issue is the use of outdated App/src/components/VideoPlayerContexts/VideoPopoverMenuContext.tsx Lines 35 to 39 in 0190b0a
It is possible to avoid this situation by using the local file for playback while using the server URL for downloading, as proposed by @bernhardoj. Let's go with the @bernhardoj's proposal cc: @Gonals |
Sounds good! |
PR is ready cc: @sobitneupane |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.95-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 2025-02-18. 🎊 For reference, here are some details about the assignees on this issue:
|
@sobitneupane @JmillsExpensify @sobitneupane The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button] |
Taking over for payment. @sobitneupane can you complete the checklist today? |
@garrettmknight @Gonals @hellohublot @sobitneupane @bernhardoj this issue is now 4 weeks old, please consider:
Thanks! |
Payment Summary:
|
Requested in ND. |
Regression Test Proposal:
Do we agree 👍 or 👎 |
BugZero Checklist:
Bug classificationSource of bug:
Where bug was reported:
Who reported the bug:
|
$250 approved for @bernhardoj |
Payment summary here @sobitneupane go ahead and request. |
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: v9.0.88-4
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/5488354
Issue reported by: Applause Internal Team
Device used: Windows 11/ Chrome
App Component: Chat Report View
Action Performed:
Expected Result:
Video with an .mp4 format is downloaded.
Actual Result:
Downloaded video is not in .mp4 format.
Workaround:
Unknown
Platforms:
Screenshots/Videos
Bug6720001_1737474016295.bandicam_2025-01-21_18-31-17-703.mp4
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @garrettmknightThe text was updated successfully, but these errors were encountered: