eclipse / openvsx

An open-source registry for VS Code extensions
https://open-vsx.org/
Eclipse Public License 2.0
1.25k stars 137 forks source link

Web extension resources return incorrect MIME type #468

Open jeanp413 opened 2 years ago

jeanp413 commented 2 years ago

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:

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

cc @amvanbaren

amvanbaren commented 2 years ago

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

jeanp413 commented 2 years ago

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?

amvanbaren commented 2 years ago

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

amvanbaren commented 1 year ago

Reminder

TODO

kineticsquid commented 1 year ago

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

amvanbaren commented 1 year ago

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