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

feat: Use application/octet-stream as a fallback media type to avoid "Unknown media type" errors #32471

Merged
merged 19 commits into from
Jun 19, 2024

Conversation

matheusbsilva137
Copy link
Contributor

@matheusbsilva137 matheusbsilva137 commented May 22, 2024

Proposed changes (including videos or screenshots)

  • Allow any file with an unknown media type (the ones not defined in IANA, Apache or nginx MIME types will be classified as application/octet-stream as default if the new setting is disabled) to be uploaded by using a application/octet-stream as the default/fallback MIME type;
  • Normalize how MIME types are identified throughout the application (by using the mime package in the back-end too)
  • Add alert to "Blocked Media Types" setting
    Captura de tela de 2024-06-17 13-15-45

Issue(s)

Steps to test or reproduce

Access a room and try uploading a drawio file in it (such as the one available in the end-to-end tests added by this PR); Expected behavior: The file should be accepted and uploaded succesfully. Check the rocketchat_uploads DB collection to confirm the file has been uploaded with the application/octet-stream media type (default one for unknown media extensions);
Current behavior: the file isn't accepted and an "Unknown media type not accepted" error is thrown.

Further comments

SUP-531

Copy link
Contributor

dionisio-bot bot commented May 22, 2024

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

Copy link

changeset-bot bot commented May 22, 2024

🦋 Changeset detected

Latest commit: 2886ac3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 34 packages
Name Type
@rocket.chat/meteor Minor
@rocket.chat/i18n Minor
@rocket.chat/mock-providers Patch
@rocket.chat/ui-contexts Major
@rocket.chat/web-ui-registration Major
@rocket.chat/fuselage-ui-kit Major
@rocket.chat/ui-client Major
@rocket.chat/gazzodown Major
@rocket.chat/livechat Patch
@rocket.chat/ui-avatar Major
@rocket.chat/ui-video-conf Major
@rocket.chat/uikit-playground Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/core-typings Minor
@rocket.chat/rest-typings Minor
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/model-typings Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/api-client Patch
@rocket.chat/license Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/ddp-client Patch
@rocket.chat/models Patch
@rocket.chat/instance-status Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@matheusbsilva137 matheusbsilva137 added this to the 6.10 milestone May 22, 2024
Copy link

codecov bot commented May 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.06%. Comparing base (3039968) to head (2886ac3).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #32471      +/-   ##
===========================================
- Coverage    56.53%   55.06%   -1.47%     
===========================================
  Files         2484     2397      -87     
  Lines        54693    53207    -1486     
  Branches     11286    10946     -340     
===========================================
- Hits         30921    29300    -1621     
- Misses       21122    21319     +197     
+ Partials      2650     2588      -62     
Flag Coverage Δ
e2e 53.36% <100.00%> (-2.80%) ⬇️
unit 72.16% <50.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@matheusbsilva137 matheusbsilva137 marked this pull request as ready for review May 24, 2024 19:51
@matheusbsilva137 matheusbsilva137 requested review from a team as code owners May 24, 2024 19:51
Copy link
Contributor

@MarcosSpessatto MarcosSpessatto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rewrite the description please, we are mentioning Reject unknown media types, but the name/description for the setting is completely different (which is good in my opinion)

apps/meteor/app/api/server/lib/getUploadFormData.ts Outdated Show resolved Hide resolved
apps/meteor/server/settings/file-upload.ts Outdated Show resolved Hide resolved
apps/meteor/tests/e2e/file-upload.spec.ts Outdated Show resolved Hide resolved
apps/meteor/tests/e2e/file-upload.spec.ts Outdated Show resolved Hide resolved
apps/meteor/tests/e2e/file-upload.spec.ts Outdated Show resolved Hide resolved
apps/meteor/tests/end-to-end/api/09-rooms.js Outdated Show resolved Hide resolved
@matheusbsilva137 matheusbsilva137 changed the title feat: Add setting to allow uploading unknown media types feat: Use application/octet-stream as a fallback media type to avoid "Unknown media type" errors Jun 13, 2024
@scuciatto scuciatto added the stat: QA assured Means it has been tested and approved by a company insider label Jun 19, 2024
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Jun 19, 2024
@kodiakhq kodiakhq bot merged commit 02dd875 into develop Jun 19, 2024
43 of 50 checks passed
@kodiakhq kodiakhq bot deleted the feat/setting-allow-upload-unknown-media branch June 19, 2024 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
squad: core stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants