openvsx
openvsx copied to clipboard
Web extension resources return incorrect MIME type
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 betext/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 beapplication/javascript
Chrome doesn't complain but Firefox gives more useful logs
cc @amvanbaren
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
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?
Ok, that would narrow it down. I don't know how many of the extensions are web extensions.
Reminder
TODO
- [x] Fix file type detection
- [ ] Re-upload all incorrect
text/plain
files - [ ] Re-upload all *.vsix packages
@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?
Yes, it's a migration that reprocesses extensions to have the file types registered correctly.