Bug Description
When using the /api/vscode/{publisher}/{extension}/latest endpoint (introduced in v2.4.0), the marketplace incorrectly serves darwin-arm64 extension variants instead of the appropriate platform-specific versions (e.g., linux-x64) due to alphabetical sorting of platform names.
Root Cause
The issue is in the ByVersion.Less() method in /storage/storage.go:
if vs[i].Version == vs[j].Version {
return vs[i].TargetPlatform < vs[j].TargetPlatform
}
When multiple platform variants exist for the same semantic version (e.g., 2.36.4@darwin-arm64, 2.36.4@linux-x64), they are sorted alphabetically by platform string. Since "darwin-arm64" < "linux-x64" alphabetically, darwin-arm64 versions are always selected first when using IncludeLatestVersionOnly.
Impact
- Extensions fail to install in VS Code/code-server running on Linux platforms
- Affects all extensions that have multiple platform-specific variants
- Introduced in v2.4.0 when the new
/latest endpoint started being used by VS Code
Example Logs
Expected behavior (linux-x64 environment should get linux-x64 variant):
ComputeTargetPlatform: linux-x64
2025-09-20 09:42:42.565 [debu] GET /files/hashicorp/terraform/2.36.4@linux-x64/hashicorp.terraform-2.36.4@linux-x64.vsix
Actual behavior (linux-x64 environment incorrectly gets darwin-arm64 variant):
ComputeTargetPlatform: linux-x64
2025-09-20 09:42:40.247 [debu] GET /files/hashicorp/terraform/2.36.4@darwin-arm64/extension/package.json
Environment
- code-marketplace version: v2.4.0
- VS Code/code-server: 1.104.0
- Platform: Linux x64 containers
- Extensions affected: Any extension with multiple platform variants (e.g., HashiCorp Terraform)
Proposed Solutions
- Platform-aware filtering: Filter versions by the requesting client's target platform before sorting
- Universal version priority: Prioritize universal platform versions when available
- Platform preference order: Define a logical platform ordering instead of alphabetical (e.g., prefer common platforms like linux-x64 over darwin-arm64)
- Client platform detection: Extract target platform from request headers or query parameters
Reproduction Steps
- Set up code-marketplace v2.4.0
- Upload an extension with multiple platform variants (e.g., versions for both
linux-x64 and darwin-arm64)
- Make a request to
/api/vscode/{publisher}/{extension}/latest from a linux-x64 environment
- Observe that darwin-arm64 variant is returned instead of linux-x64
Workaround
Temporarily downgrade to v2.3.1 or modify the version sorting logic to prioritize the appropriate platform for your environment.
Bug Description
When using the
/api/vscode/{publisher}/{extension}/latestendpoint (introduced in v2.4.0), the marketplace incorrectly servesdarwin-arm64extension variants instead of the appropriate platform-specific versions (e.g.,linux-x64) due to alphabetical sorting of platform names.Root Cause
The issue is in the
ByVersion.Less()method in/storage/storage.go:When multiple platform variants exist for the same semantic version (e.g.,
2.36.4@darwin-arm64,2.36.4@linux-x64), they are sorted alphabetically by platform string. Since"darwin-arm64" < "linux-x64"alphabetically, darwin-arm64 versions are always selected first when usingIncludeLatestVersionOnly.Impact
/latestendpoint started being used by VS CodeExample Logs
Expected behavior (linux-x64 environment should get linux-x64 variant):
Actual behavior (linux-x64 environment incorrectly gets darwin-arm64 variant):
Environment
Proposed Solutions
Reproduction Steps
linux-x64anddarwin-arm64)/api/vscode/{publisher}/{extension}/latestfrom a linux-x64 environmentWorkaround
Temporarily downgrade to v2.3.1 or modify the version sorting logic to prioritize the appropriate platform for your environment.