Skip to content

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
maruthang:fix/issue-310777-unknown-uri-cluster
Closed

fix(sessions): use non-empty path for unknown-workspace fallback URI to prevent joinPath crashes (#310777)#310819
maruthang wants to merge 1 commit intomicrosoft:mainfrom
maruthang:fix/issue-310777-unknown-uri-cluster

Conversation

@maruthang
Copy link
Copy Markdown
Contributor

What

Replace the repo-less session fallback URI URI.parse('unknown:') with URI.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.joinPath throws cannot call joinPath on URI without path for such URIs, so any code iterating workspace folders and calling folder.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 compareAndDeleteFolderConfiguration all hit this path for Copilot agent sessions without repository metadata.

How

URI.from({ scheme: 'unknown', path: '/' }) produces a URI whose path is non-empty, so URI.joinPath and friends behave correctly. Fallback is only taken when repoUri === 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 with metadata: undefined, read session.workspace.get(), and assert the fallback URI has a non-empty path and that URI.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 compareAndDeleteFolderConfiguration race-condition bug tracked in #310369 — that's a distinct fix.)

Fixes #310777

@aeschli
Copy link
Copy Markdown
Contributor

aeschli commented Apr 20, 2026

Thanks a lot, it's fixed by #311319 I used your test case

@aeschli aeschli closed this Apr 20, 2026
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.

[Error] unhandlederror-AbstractContextKeyService has been disposed

3 participants