openvsx icon indicating copy to clipboard operation
openvsx copied to clipboard

VS Code query response is listing files in node_modules

Open jeanp413 opened this issue 2 years ago • 5 comments

VS Code makes this query to fetch the popular extensions view but the response is 19 MB

curl 'http://localhost:8080/vscode/gallery/extensionquery' \
  -H 'accept: application/json;api-version=3.0-preview.1' \
  -H 'content-type: application/json' \
  --data-raw '{"filters":[{"criteria":[{"filterType":8,"value":"Microsoft.VisualStudio.Code"},{"filterType":12,"value":"4096"}],"pageNumber":1,"pageSize":50,"sortBy":4,"sortOrder":0}],"assetTypes":[],"flags":950}' \
  --compressed

The response is listing all the files in the node_modules folder of the extension :grimacing:

{
  "assetType": "Microsoft.VisualStudio.Code.WebResources/extension/out/client/node_modules/linebreak.js.map",
  "source": "http://localhost:8080/api/ms-python/python/2019.10.44104/file/extension/out/client/node_modules/linebreak.js.map"
},
{
  "assetType": "Microsoft.VisualStudio.Code.WebResources/extension/out/client/node_modules/node-stream-zip.js",
  "source": "http://localhost:8080/api/ms-python/python/2019.10.44104/file/extension/out/client/node_modules/node-stream-zip.js"
},
{
  "assetType": "Microsoft.VisualStudio.Code.WebResources/extension/out/client/node_modules/node-stream-zip.js.map",
  "source": "http://localhost:8080/api/ms-python/python/2019.10.44104/file/extension/out/client/node_modules/node-stream-zip.js.map"
},
{
  "assetType": "Microsoft.VisualStudio.Code.WebResources/extension/out/client/node_modules/onigasm/lib/onigasm.wasm",
  "source": "http://localhost:8080/api/ms-python/python/2019.10.44104/file/extension/out/client/node_modules/onigasm/lib/onigasm.wasm"
},
{
  "assetType": "Microsoft.VisualStudio.Code.WebResources/extension/out/client/node_modules/pdfkit.js",
  "source": "http://localhost:8080/api/ms-python/python/2019.10.44104/file/extension/out/client/node_modules/pdfkit.js"
},

jeanp413 avatar May 20 '22 03:05 jeanp413

cc @amvanbaren

jeanp413 avatar May 20 '22 03:05 jeanp413

It looks like the MS marketplace doesn't include any WebResources in the response.

curl --location --request POST 'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json;api-version=3.0-preview.1' \
--data-raw '{"filters":[{"criteria":[{"filterType":8,"value":"Microsoft.VisualStudio.Code"},{"filterType":12,"value":"4096"}],"pageNumber":1,"pageSize":50,"sortBy":4,"sortOrder":0}],"assetTypes":[],"flags":950}'

Also when I narrow down the query to ms-python.python it doesn't include WebResources

curl --location --request POST 'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json;api-version=3.0-preview.1' \
--data-raw '{"filters":[{"criteria":[{"filterType":7,"value":"ms-python.python"},{"filterType":8,"value":"Microsoft.VisualStudio.Code"},{"filterType":12,"value":"4096"}],"pageNumber":1,"pageSize":50,"sortBy":4,"sortOrder":0}],"assetTypes":[],"flags":950}'

amvanbaren avatar May 26 '22 10:05 amvanbaren

Seems Microsoft.VisualStudio.Code.WebResources is a custom attribute from openvsx, I don't see it in VSCode source code

jeanp413 avatar May 26 '22 15:05 jeanp413

And looking at the blame info, AssetTypes hasn't changed in the past 5 years: https://github.com/microsoft/vscode/blame/cc86b15a44fe28300180108f4d95cacee98717dc/src/vs/platform/extensionManagement/common/extensionGalleryService.ts#L190-L207

It was introduced in openvsx in PR #262: https://github.com/eclipse/openvsx/pull/262/files#diff-17aa6856a7169de1018e7f3a9db6305371243d8c52fcb023f4d063a8bcf977bc

amvanbaren avatar May 26 '22 18:05 amvanbaren

I think we can delete it after https://github.com/eclipse/openvsx/pull/435 is running in production and https://github.com/gitpod-io/openvscode-server/pull/331 is merged and deployed too

jeanp413 avatar May 26 '22 18:05 jeanp413

@jeanp413 When I run

curl 'https://open-vsx.org/vscode/gallery/extensionquery' \
  -H 'accept: application/json;api-version=3.0-preview.1' \
  -H 'content-type: application/json' \
  --data-raw '{"filters":[{"criteria":[{"filterType":8,"value":"Microsoft.VisualStudio.Code"},{"filterType":12,"value":"4096"}],"pageNumber":1,"pageSize":50,"sortBy":4,"sortOrder":0}],"assetTypes":[],"flags":950}' \
  --compressed

the response no longer contains web resources. extensionquery.json.txt

amvanbaren avatar Nov 22 '22 10:11 amvanbaren