fix(sessions): use non-empty path for unknown-workspace fallback URI to prevent joinPath crashes (#310777)#310819
Closed
maruthang wants to merge 1 commit intomicrosoft:mainfrom
Closed
Conversation
…to prevent joinPath crashes (microsoft#310777)
Contributor
|
Thanks a lot, it's fixed by #311319 I used your test case |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Replace the repo-less session fallback URI
URI.parse('unknown:')withURI.from({ scheme: 'unknown', path: '/' })so downstream workspace-folder operations don't explode on a path-less URI.Why
URI.parse('unknown:')yields a URI with an empty path.URI.joinPaththrowscannot call joinPath on URI without pathfor such URIs, so any code iterating workspace folders and callingfolder.toResource(...)/URI.joinPath(folder.uri, ...)crashed — fanning out into ~13 telemetry buckets (#310777, #310752, #310751, #310369, #310370, #310368, #310364, #310365, #310366, #310357, #310180, #308827).Snippets service, workspace extensions config, preferences editor menu, and
compareAndDeleteFolderConfigurationall hit this path for Copilot agent sessions without repository metadata.How
URI.from({ scheme: 'unknown', path: '/' })produces a URI whose path is non-empty, soURI.joinPathand friends behave correctly. Fallback is only taken whenrepoUri === undefined; sessions with real repo URIs are unaffected.This was the approach flagged (but deferred) by @aeschli when landing PR #309777.
Test plan
New test in
copilotChatSessionsProvider.test.ts: construct a session withmetadata: undefined, readsession.workspace.get(), and assert the fallback URI has a non-empty path and thatURI.joinPath(fallbackUri, '.vscode', 'settings.json')does not throw (both were broken pre-fix).Closes the root cause for the following telemetry buckets: #310777, #310752, #310751, #310370, #310368, #310364, #310365, #310366, #310357, #310180, #308827.
(Does NOT close the separate
compareAndDeleteFolderConfigurationrace-condition bug tracked in #310369 — that's a distinct fix.)Fixes #310777