Skip to content

Private Marketplace extension blocking: add gallery and install enforcement - #333859

Merged
Karthik Nadig (karthiknadig) merged 5 commits into
microsoft:mainfrom
mcumming:dev/mcumming/blocked-extension-reason
Oct 15, 2026
Merged

Karthik Nadig (karthiknadig) merged 5 commits into
microsoft:mainfrom
mcumming:dev/mcumming/blocked-extension-reason

Conversation

@mcumming

@mcumming Michael Cummings (MSFT) (mcumming) commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

The Private Marketplace evaluates an administrative allow/deny policy on extension queries. Previously, a denial reached the client only as an absence: the extension was missing from results or installation failed without explaining the policy decision.

Private Marketplace now emits the approved Extension Blocking wire contract: an extension- or version-level blocked flag with a blocking object. This PR implements the platform portion of that contract in VS Code.

What it does

  • Parses extension- and version-level blocking metadata.
  • Treats either the flag or object as blocked, as required for fail-safe consumer handling.
  • Ignores unknown flag tokens and object fields.
  • Degrades missing, null, wrong-typed, or unknown origins to service, as required by the approved contract.
  • Distinguishes organization-policy and marketplace-originated blocks in user-facing install errors.
  • Prevents acquisition of a blocked extension.
  • Skips blocked versions while selecting a version, allowing an older permitted version to remain available.
  • Supports an explicit exact-version metadata lookup for downstream installed-extension state without making blocked versions installable by default.

This PR is intentionally limited to gallery parsing and platform install enforcement. Installed-extension propagation, auto-update behavior, context keys, status UI, toggle UI, and chat-search filtering remain in #341049 because remediation and wording for an extension that is already installed require their own workbench behavior.

Version-level behavior

Version-level blocks do not imply that the whole extension is blocked. Selection skips a blocked version and uses the first older permitted version when one exists, including the existing pre-release fallback path.

By default, an explicitly requested blocked version returns no matching version. An internal opt-in query can retrieve that exact version's blocking metadata so the workbench can preserve the state of an already-installed blocked version; this does not change normal acquisition selection. If every version is blocked in a compatible query, no compatible extension is returned. This PR does not add a blocking-specific result state to the gallery selection API.

Install errors

Whole-extension blocks that reach the install service fail with the origin-specific blocking message and ExtensionManagementErrorCode.NotAllowed.

Existing allow-list and platform-incompatibility behavior is preserved. Their Markdown-capable canInstall results are not passed into plain-text CLI and dialog consumers. NotAllowed is handled by the existing informational install-failure dialog and by Settings Sync's skip-and-do-not-retry path.

Capability negotiation

The approved contract does not define a gallery-manifest capability, and Private Marketplace is already emitting the metadata. The client therefore reads the additive fields directly rather than requiring a VS Code-specific capability that the deployed producer does not advertise.

Testing

Tests cover:

  • Flag without object and object without flag.
  • Whole-token flag matching and unknown tokens.
  • Missing, null, wrong-typed, and unknown origin fallback.
  • Extension-level precedence over version-level metadata.
  • Origin-specific message text.
  • Platform canInstall behavior.
  • The public install path and NotAllowed error.
  • Preservation of existing plain platform errors for other canInstall failures.
  • Skipping a blocked latest version in display, pre-release fallback, and compatible queries.
  • Default exact-version rejection and opt-in exact-version metadata retrieval.
  • All-versions-blocked query outcomes.
  • Browser and Electron execution of the gallery regression suite.

The gallery tests use deterministic stubbed responses matching data already emitted by Private Marketplace.


🤖 This pull request description was authored by GitHub Copilot CLI on behalf of Michael Cummings (MSFT) (@mcumming).

Copilot AI balanced review requested due to automatic review settings September 1, 2026 20:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Installed extension models can retain stale blocking metadata and bypass the new UI and chat safeguards.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 Medium severity · 3 Low severity

New issues introduced by this change (4)
Severity Finding
Medium severity src/​vs/​workbench/​contrib/​extensions/​browser/​extensionsWorkbenchService.ts — blockingInfo can remain stale for installed extensions. queryGallery/getExtensions return an…
Low severity src/​vs/​platform/​extensionManagement/​common/​abstractExtensionManagementService.ts — This multi-line comment restates the branch and error construction. A short note captures the…
Low severity src/​vs/​platform/​extensionManagement/​common/​extensionGalleryService.ts — This long JSDoc duplicates implementation details and caller behavior, so it is likely to drift as…
Low severity src/​vs/​platform/​extensionManagement/​common/​extensionGalleryService.ts — This multi-line inline comment narrates the surrounding selection logic and includes a fallback…
What changed in this PR

Adds client support for marketplace extension-blocking metadata and enforces it across installation, updates, UI, and chat search.

Changes:

  • Parses extension- and version-level blocking metadata.
  • Prevents blocked extension acquisition and surfaces origin-specific messages.
  • Adds contract parsing and message tests.
File Description
searchExtensionsTool.ts Excludes blocked extensions from chat results.
extensions.ts Exposes blocking metadata in the workbench model.
extensionsWorkbenchService.ts Applies blocking to updates and installation.
extensionsActions.ts Disables actions and displays blocked status.
extensionManagement.test.ts Tests origin-specific messages.
extensionGalleryService.test.ts Tests blocking contract parsing.
extensionManagementUtil.ts Builds localized blocking messages.
extensionManagement.ts Defines public blocking types.
extensionGalleryService.ts Parses blocking data and filters versions.
abstractExtensionManagementService.ts Enforces blocks and preserves failure reasons.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@roblourens roblourens left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Experimental performance review bot]

Automated experimental performance review.

(Written by Copilot)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together. The parsing rules and the fail-safe handling of malformed payloads are well thought out.

Please split this into two PRs:

  1. Parsing + install gating (platform layer): getBlockingInfo and the raw types, version selection in isValidVersion, canInstall / checkAndGetCompatibleVersion, and auto-update gating, with tests that use a stubbed gallery response.
  2. UI, stacked on top: ExtensionStatusAction, the extensionDisallowInstall context key, the auto-update toggle, searchExtensionsTool, and the installed-extension refresh in extensionsWorkbenchService.

That lets us settle install behavior while the spec is still in review, and keeps the UI discussion focused on what we show for extensions that are already installed, which isn't designed yet.

Main issues (details inline):

  • Throwing canInstall.value turns the existing allow-list and platform-incompatible errors into raw markdown in the dialog and CLI.
  • A missing or unknown origin falls back to the most alarming message.
  • Installed extensions are told they "must not be used" but stay enabled.
  • Version-level blocks still show up as "not found" / "not compatible" on install.
  • Not gated on a gallery capability while the contract is in review.
  • Tests don't exercise the behavior changes.

Review assisted by Copilot.

@mcumming

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed review. For additional context, the Extension Blocking specification has been approved by the VS Marketplace team, although its metadata had not yet been updated. Private Marketplace is also already emitting the blocked flag and blocking object.

I reduced this PR to the platform portion: contract parsing, version selection, install gating, error handling, and behavioral tests. Installed-extension propagation, auto-update behavior, context keys, status and toggle UI, and chat filtering have been removed for separate work, where the installed-extension remediation and wording can be reviewed independently.

The revision also restores the existing allow-list/platform error behavior, uses NotAllowed for whole-extension blocks, documents the current version-level outcomes, and expands the deterministic gallery and public-install-path tests.


🤖 This reply was authored by GitHub Copilot CLI on behalf of Michael Cummings (MSFT) (@mcumming).

@mcumming Michael Cummings (MSFT) (mcumming) changed the title Surface extensions blocked by the marketplace Private Marketplace extension blocking: add gallery and install enforcement Oct 12, 2026
The marketplace previously omitted extensions it would not serve, so a
user searching for one saw an empty result and no reason for it. It now
returns the record carrying a `blocked` flag instead, and this reads
that flag and explains the block rather than letting the extension
disappear.

The flag comes at two granularities -- a whole extension, or a single
version while the others remain available -- and both are read. A
blocked version is skipped when selecting one to acquire, so selection
falls through to a permitted version, in display paths as well as
install paths: a version pinned out by policy is usually the newest,
and showing it would strand an extension whose earlier versions are
perfectly usable. The two granularities are not distinguished in the
result, because a block only reaches a user once no version is
permitted, and at that point the extension is unavailable to them
whichever granularity produced it.

Blocked extensions are still returned by the gallery, so enforcement
lives at the decision points -- canInstall, auto-update, and the
extensionDisallowInstall context key -- rather than by filtering them
out of results. The block takes precedence over deprecation, and the
message distinguishes an organization policy decision from a
marketplace statement, since conflating the two either alarms users
about a routine policy decision or understates a marketplace finding.

Report the reason canInstall determined when refusing an install, rather
than discarding it for a fixed platform-incompatibility message. That
message was already wrong for an allow list denial, and adding a second
cause to the same path would have made a blocked extension claim it was
unavailable for the machine's platform, sending the user to look for one
that could run it. The paths reaching this are the ones with no other
signal: settings sync, the command line, and the URI handler.

Only the flag and the origin are read. The contract also defines a
reason, none of whose values the registry populates today: allow-list
denials are the only blocks issued, and they carry origin policy. Origin
is kept rather than collapsed to a boolean because attributing a
marketplace block to the user's own organization would be misleading.
Absent, unrecognized, and wrong-typed values degrade to the marketplace
wording rather than failing the parse, which would have taken down the
whole query rather than the one extension.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 2c07f98f-e549-41c2-af5b-7f197c533c8c
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 2c07f98f-e549-41c2-af5b-7f197c533c8c
Exclude a blocked latest version from the display-query fallback so the existing all-versions retry can select an older permitted release. Cover the latest-only response shape and retry sequence.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 47b6e35c-f0a9-4b72-9c0e-ea4531326362
@mcumming
Michael Cummings (MSFT) (mcumming) force-pushed the dev/mcumming/blocked-extension-reason branch from f94a1e3 to f99f285 Compare October 13, 2026 19:01
Run the display-query fallback regression against the universal target so the synthetic versions are valid in both desktop and web test environments.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 2c07f98f-e549-41c2-af5b-7f197c533c8c
Select the first unblocked fallback version and allow callers to opt into retrieving blocking metadata for an exact blocked version. Cover pre-release fallback and exact-version metadata behavior.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 2c07f98f-e549-41c2-af5b-7f197c533c8c
@mariaghiondea

Copy link
Copy Markdown

Karthik Nadig (@karthiknadig) this is ready for your review

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting this and working through the feedback. The plain-text error messages, the NotAllowed handling and the new behavioral tests look good. The contract-based reasoning for the origin fallback and for skipping a capability gate makes sense to me.

A few non-blocking nits inline. They can be handled in #341049, which is stacked on this branch.


Review assisted by Copilot.

@mcumming

Copy link
Copy Markdown
Contributor Author

The branch has been rebased and the refreshed cross-platform CI is green, including Linux, macOS, and Windows Browser coverage.

The follow-up fixes now:

  • make the latest-only display regression platform-independent in the Browser runner;
  • select the first unblocked fallback version, including pre-release-only fallback cases;
  • support an explicit exact-version metadata lookup for preserving the state of an already-installed blocked version without changing normal acquisition behavior.

The focused Browser and Electron gallery suites, targeted ESLint, and client type-check also pass locally. There are no unresolved review threads. The only remaining pending status is the shared external VS Code PR Check.

Karthik Nadig (@karthiknadig), could you please re-review when convenient? I do not have permission to formally re-request your review on this upstream PR.


🤖 This reply was authored by GitHub Copilot CLI on behalf of Michael Cummings (MSFT) (@mcumming).

@karthiknadig
Karthik Nadig (karthiknadig) merged commit 9ebdca5 into microsoft:main Oct 15, 2026
35 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.143.0 milestone Oct 15, 2026
@mcumming
Michael Cummings (MSFT) (mcumming) deleted the dev/mcumming/blocked-extension-reason branch October 15, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants