openvsx icon indicating copy to clipboard operation
openvsx copied to clipboard

Web extension resources return incorrect MIME type

Open jeanp413 opened this issue 2 years ago • 6 comments

From https://github.com/gitpod-io/gitpod/issues/10523

It seems the root cause of that bug is that Web extension resources served from openvsx return an incorrect MIME type For example:

  • Requesting for https://openvsxorg.blob.core.windows.net/resources/pomdtr/excalidraw-editor/3.0.1/extension/public/static/css/main.9cab4879.chunk.css returns Content-Type: text/plain when it should be text/css
  • Requesting for https://open-vsx.org/vscode/asset/pomdtr/excalidraw-editor/3.0.1/Microsoft.VisualStudio.Code.WebResources/extension/public/static/js/main.34d01954.chunk.js returns Content-Type: text/plain when it should be application/javascript

Chrome doesn't complain but Firefox gives more useful logs image

cc @amvanbaren

jeanp413 avatar Jun 09 '22 02:06 jeanp413

I've replaced the fileType detection logic with Apache Tika. It supports more file types out of the box and it lets you configure custom file types too.

The bad news is that the getFileType method is also used when uploading a file to cloud storage: https://github.com/eclipse/openvsx/blob/72706d126e642d6d714c5ae40bc970dd35340986/server/src/main/java/org/eclipse/openvsx/storage/GoogleCloudStorageService.java#L71-L72 https://github.com/eclipse/openvsx/blob/72706d126e642d6d714c5ae40bc970dd35340986/server/src/main/java/org/eclipse/openvsx/storage/AzureBlobStorageService.java#L72-L73 This means that all files that currently are incorrectly of type text/plain and all vsix packages (type should be application/vsix instead of application/octet-stream) need to be downloaded and re-uploaded with the correct Content-Type.

Luckily the release that is not running in production yet uses JobRunr to perform a long running migration in the background. The same technique can be used to re-upload files with the right Content-Type.

TODO

  • [x] Fix file type detection
  • [ ] Re-upload all incorrect text/plain files
  • [ ] Re-upload all *.vsix packages

amvanbaren avatar Jun 09 '22 17:06 amvanbaren

This only matters for web extension (__web_extension tag) and I guess there're not many of those :crossed_fingers:, do you have some numbers about the number of web extension?

jeanp413 avatar Jun 09 '22 17:06 jeanp413

Ok, that would narrow it down. I don't know how many of the extensions are web extensions.

amvanbaren avatar Jun 09 '22 18:06 amvanbaren

Reminder

TODO

  • [x] Fix file type detection
  • [ ] Re-upload all incorrect text/plain files
  • [ ] Re-upload all *.vsix packages

amvanbaren avatar Nov 22 '22 09:11 amvanbaren

@amvanbaren Just making sure I'm following the discussion. This is not a change we're asking extension authors to make, but rather a batch process to 're-publish' extensions to have the file types registered correctly?

kineticsquid avatar Jan 17 '23 18:01 kineticsquid

Yes, it's a migration that reprocesses extensions to have the file types registered correctly.

amvanbaren avatar Jan 18 '23 09:01 amvanbaren