Repository navigation
[cherry-pick] managed settings: keep policy through transient refresh failures - #337739
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The retention behavior is correctly implemented and tested; only a non-blocking comment-style cleanup remains.
Review effort: Balanced
Findings: 1
What changed in this PR
Retains cached server-managed policy through transient refresh failures without renewing its timestamp.
Changes:
- Preserve stale managed settings after network, authentication, rate-limit, server, or malformed-response failures.
- Update regression coverage for stale-cache retention across no-response, 401, and 403 failures.
| File | Description |
|---|---|
defaultAccount.ts |
Retains the last scoped policy after transient failures. |
defaultAccount.test.ts |
Verifies retained policy and unchanged timestamps. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+1231
to
+1233
| // A failed fetch (including a 401/403, which may be transient) is not evidence that policy was withdrawn: | ||
| // keep the last successful response even once stale, with its original timestamp so the failure does not | ||
| // count as a refresh and it is still refetched. |
roblourens
approved these changes
Sep 24, 2026
roblourens
approved these changes
Sep 24, 2026
roblourens
approved these changes
Sep 24, 2026
Vritant Bhardwaj (vritant24)
approved these changes
Sep 24, 2026
|
Ghazanfar Shahzad 00923007410070 // 00923158281285 //Gujranwala make roud Asad kalone St no 2 ho no 1 Punjab Pakistan // |
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.

Cherry-pick of #337583 from
main.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
forceRemoteSettingsRefreshnow 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:
forceRemoteSettingsRefreshstill fails closed.Follow-up
getDefaultAccountForAuthenticationProviderreturnnull, sosetDefaultAccount(null)clears the policy without applying this retention. This path predates managed settings: fix stale cache case when moving to unavailable #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.