Repository navigation
managed settings: fix stale cache case when moving to unavailable - #330896
Merged
Merged
Conversation
Dmitriy Vasyura (dmitrivMS)
approved these changes
Aug 14, 2026
joshspicer
enabled auto-merge (squash)
August 14, 2026 16:47
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes managed-settings cache expiration when remote settings become unavailable.
Changes:
- Preserves the cached response timestamp after failed refreshes.
- Drops stale managed settings instead of renewing them.
- Adds regression coverage for repeated unavailable responses.
Show a summary per file
| File | Description |
|---|---|
defaultAccount.ts |
Corrects unavailable-response cache handling. |
defaultAccount.test.ts |
Tests cache aging and expiration. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
joshspicer
disabled auto-merge
August 14, 2026 16:51
Ross Wollman (rwoll)
added a commit
that referenced
this pull request
Sep 23, 2026
Drop the 24-hour retention bound. Failed refreshes, including 401/403 responses that a token refresh or SSO sign-in may resolve, keep the last successful response without renewing its timestamp; only a service answer, sign-out, or account or scope change clears it. This matches the retention before #330896 while keeping its fix that a failure never renews the cache. Co-authored-by: Copilot <[email protected]>
Ross Wollman (rwoll)
added a commit
that referenced
this pull request
Sep 24, 2026
…7583) Copilot's OTel reload notification (reworked in #336701) exposed a managed-settings refresh regression from #330896. Enterprise users see "Copilot OTel endpoint will change to http://localhost:4318 after reload." every few hours, especially after idle, and reloading clears chat. ## Cause Since #330896, a cached server-managed-settings response expires one hour after the last successful fetch. If a refresh fails after that (no response, 401/403, 429, 5xx, malformed), the policy is dropped rather than kept. A policy-backed OTel endpoint then reverts to its default and the notification appears. The next successful fetch restores the policy, so it keeps switching back and forth. Every other server-managed control switches back and forth in the same way, so for the length of the gap their restrictions are silently lifted. ## Change Keep the policy unless the service answers affirmatively that it should change. A failed refresh without `forceRemoteSettingsRefresh` now keeps the last successful response, however old, with its original timestamp. The failure therefore doesn't count as a refresh, and the next poll or focus retries. A 401/403 is treated as a failure because it can be temporary, for example while a token refreshes. This keeps #330896's fix that a failure never renews the cache timestamp, and reverts only its dropping of stale policy. Before #330896, failures also kept the previous policy, but they renewed the timestamp. These still behave as before: - A 200 replaces the policy; a 404 or 466 clears it. - Sign-out, or an account or scope change, clears or stops reusing the policy. - `forceRemoteSettingsRefresh` still fails closed. ## Follow-up - A thrown session lookup error still makes `getDefaultAccountForAuthenticationProvider` return `null`, so `setDefaultAccount(null)` clears the policy without applying this retention. This path predates #330896 and changes account availability, so it needs a separate PR. - `managedSettingsActive` (set when the server returns settings that no VS Code policy uses) is never cleared once set. This bug existed before this PR and will be fixed separately. ## Validation - `defaultAccount.test.ts`: 49 passing. The updated test fails without this change. - Account and policy suites: 250 passing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.