Skip to content

[Error] [UriError] joinPath on URI without path#311319

Merged
aeschli merged 2 commits intomainfrom
aeschli/hungry-silkworm-698
Apr 20, 2026
Merged

[Error] [UriError] joinPath on URI without path#311319
aeschli merged 2 commits intomainfrom
aeschli/hungry-silkworm-698

Conversation

@aeschli
Copy link
Copy Markdown
Contributor

@aeschli aeschli commented Apr 20, 2026

Fixes #310752

Copilot AI review requested due to automatic review settings April 20, 2026 07:27
@aeschli aeschli enabled auto-merge (squash) April 20, 2026 07:27
@aeschli aeschli self-assigned this Apr 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 20, 2026

Screenshot Changes

Base: 341ef7db Current: 0dedbbc1

Changed (6)

chat/aiCustomizations/aiCustomizationManagementEditor/McpBrowseMode/Dark
Before After
before after
agentSessionsViewer/CompletedUnread/Dark
Before After
before after
agentSessionsViewer/CompletedUnread/Light
Before After
before after
agentSessionsViewer/WithMarkdownBadge/Dark
Before After
before after
agentSessionsViewer/WithMarkdownBadge/Light
Before After
before after
agentSessionsViewer/ApprovalRowLongLabel/Light
Before After
before after

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an Agents-window crash caused by calling URI.joinPath on a repository URI that had an empty path when repository metadata was missing.

Changes:

  • Ensure the fallback repository URI includes a non-empty path (unknown:///) so downstream joinPath usage doesn’t throw.
Show a summary per file
File Description
src/vs/sessions/contrib/copilotChatSessions/browser/copilotChatSessionsProvider.ts Adjusts the fallback repository URI to include a path, preventing joinPath from throwing when repo metadata is absent.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 2

Comment on lines 977 to 979
const repository: ISessionRepository = {
uri: repoUri ?? URI.parse('unknown:'),
uri: repoUri ?? URI.parse('unknown:///'),
workingDirectory: worktreeUri,
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a crash path (repo URI missing -> joinPath throws), but there’s no regression test covering the repoUri === undefined case. The existing unit tests always set metadata.repositoryPath, so this scenario isn’t exercised; consider adding a test that creates an agent session without repository metadata and asserts the adapted workspace/repository URIs are still safe to joinPath against (no empty uri.path).

See below for a potential fix:

	private _toSafeWorkspaceUri(uri: URI | undefined): URI {
		const safeUri = uri ?? URI.from({ scheme: 'unknown', path: '/' });
		return safeUri.path ? safeUri : safeUri.with({ path: '/' });
	}

	private _buildWorkspace(session: IAgentSession): ISessionWorkspace | undefined {
		const [repoUri, worktreeUri, branchName, baseBranchName, baseBranchProtected] = this._extractRepositoryFromMetadata(session);
		const safeRepositoryUri = this._toSafeWorkspaceUri(repoUri);
		const safeWorkingDirectoryUri = this._toSafeWorkspaceUri(worktreeUri ?? repoUri);

		const repository: ISessionRepository = {
			uri: safeRepositoryUri,
			workingDirectory: safeWorkingDirectoryUri,

Copilot uses AI. Check for mistakes.
@aeschli aeschli merged commit 8c98219 into main Apr 20, 2026
26 checks passed
@aeschli aeschli deleted the aeschli/hungry-silkworm-698 branch April 20, 2026 08:58
@vs-code-engineering vs-code-engineering Bot added this to the 1.118.0 milestone 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] [UriError] joinPath on URI without path — snippetService / _initWorkspaceFolderSnippets

3 participants