Repository navigation
Cache and coalesce marketplace protected resource discovery - #343687
Karthik Nadig (karthiknadig) merged 5 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Malformed discovery metadata can remain cached for five minutes, preventing immediate recovery after the endpoint is corrected.
1 open issue
What changed in this PR
This PR adds bounded caching to Microsoft marketplace protected-resource discovery, reducing repeated requests while preserving per-lookup token acquisition.
Changes:
- Cache successful discovery for five minutes and coalesce concurrent requests.
- Guard interactive consent against stale metadata and provider lifecycle changes.
- Add deterministic tests for expiration, retries, URL changes, and consent races.
| File | Description |
|---|---|
src/vs/workbench/services/extensionManagement/test/electron-browser/extensionGalleryAccountService.test.ts |
Adds cache lifecycle and stale-consent regression tests. |
src/vs/workbench/services/extensionManagement/electron-browser/extensionGalleryAccountService.ts |
Implements discovery caching, request coalescing, and consent guards. |
Review effort: Balanced
|
Karthik Nadig (@karthiknadig) this is ready for your review. Thank you. |
d6f7bf7 to
895f5d7
Compare
|
Karthik Nadig (@karthiknadig) this is ready for your review 🙏 |
Karthik Nadig (karthiknadig)
left a comment
There was a problem hiding this comment.
LGTM. Only successful, validated discovery is cached, keyed by the full service URL, and concurrent lookups share one request. One optional nit inline.
This conflicts with #343689 in extensionGalleryAccountService.ts, so it will need a rebase after that lands.
Review assisted by Copilot.
Coalesce concurrent discovery and reuse successful metadata for five minutes per active service URL. Reject stale consent work after marketplace or metadata changes. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 33fab878-5295-4cc5-9011-f5bbdb034eec
Assert accessToken rather than the entire extensible account result in reuse, coalescing, and retry tests. Production metadata cache behavior is unchanged. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 33fab878-5295-4cc5-9011-f5bbdb034eec
Reject malformed authorization server lists and unusable issuer URLs, and validate supported scope tokens before returning cacheable metadata. Keep corrected discovery immediately retryable and preserve valid Entra authorities and default scopes. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 33fab878-5295-4cc5-9011-f5bbdb034eec
Check metadata caching for omitted and empty scopes through repeated passive account resolution. Retain exact interactive consent assertions for explicit resource scopes without depending on identity-scope fallback. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 33fab878-5295-4cc5-9011-f5bbdb034eec
Cache confirmed all-404/410 protected-resource discovery absence for thirty seconds and bypass only negative entries during explicit sign-in. Preserve uncached invalid-scope diagnostics without resource acquisition, and retain positive-cache validation and lifecycle guards. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 33fab878-5295-4cc5-9011-f5bbdb034eec
f1e8bd6 to
7ef36b8
Compare
|
Karthik Nadig (@karthiknadig) do you approve this one? |
Karthik Nadig (karthiknadig)
left a comment
There was a problem hiding this comment.
LGTM. The negative cache only applies when every discovery probe returns 404 or 410, lasts 30 seconds, and is bypassed on explicit sign-in, which covers my earlier nit.
One thing for the rebase onto #343689, since the two conflict in doGetAccount: the new invalidScopes path returns session.accessToken. Please make sure it resolves to return {} there, like the other sign-in-token fallbacks #343689 removes.
Review assisted by Copilot.

Related to microsoft/vscode#325412.
Discovery cache
Cache and coalesce Microsoft marketplace protected-resource discovery in the provider, retaining only the active full service URL, including its path.
Validation and lifecycle boundaries
Validate authorization-server URL shape and scope-token syntax before positive caching. Authorization servers must be absolute HTTPS identifiers without credentials, query, fragment, raw whitespace, or backslashes. Scope entries must be nonempty RFC 6749 scope-token strings. A provider-private invalid-scope reason is retained without caching malformed data; syntax-valid scope lists remain intact. The cache does not replace credential-acquisition policy; the scoped-token prerequisite supplies the resource-usability guards.
Provider replacement and service-URL changes invalidate reuse. Consent ignores obsolete discovery/session results after cache replacement, expiry, URL changes, or disposal. The cache stores discovery metadata, not bearer credentials; resource-session lookup and token lifetime remain independent.
This is a provider-local cache with no new setting, public event, shared discovery contract, or general-purpose caching layer.
Validation
npm run typecheck-clientnode build\next\build-fast.ts --client-only$env:VSCODE_SKIP_PRELAUNCH = '1'; .\scripts\test.bat --run src\vs\workbench\services\extensionManagement\test\electron-browser\extensionGalleryAccountService.test.ts --run src\vs\workbench\services\extensionManagement\test\electron-browser\extensionGalleryManifestService.test.ts --reporter dotExercise fixed positive/negative expiries, concurrent reuse, every absence/error classification, explicit-sign-in bypass, metadata correction, full-URL/provider invalidation, and stale discovery/consent races. Verify resource tokens are acquired independently of cached metadata.
No live private-marketplace or interactive identity-provider flow was exercised.
Drafted with GitHub Copilot.