Skip to content

Conversation

@bryanchen-d
Copy link
Contributor

Summary

When anonymizing file paths in telemetry data, preserve the extension name and path within VS Code extension directories while redacting the parent folder containing user information.

Problem

Extension host error callstacks in telemetry were being fully redacted:

at uv.provideCodeActions (<REDACTED: user-file-path>:144:145516)

This made it impossible to identify which extension was causing errors.

Solution

The anonymizeFilePaths function now recognizes VS Code extension paths and preserves them:

Matches:

  • User extensions: .vscode/extensions/, .vscode-insiders/extensions/, .vscode-server/extensions/, etc.
  • Built-in extensions: resources/app/extensions/

After:

at uv.provideCodeActions (<REDACTED: user-file-path>/.vscode/extensions/ms-python.python-2024.0.1/out/extension.js:144:145516)

The user's home directory is redacted, but the extension name and file path within it are preserved for debugging.

Testing

  • Added test case for extension path preservation
  • All 31 telemetry tests pass

When anonymizing file paths in telemetry data, preserve the extension
name and path within VS Code extension directories while redacting
the parent folder containing user information.

Matches:
- User extensions: .vscode/extensions/, .vscode-insiders/extensions/, etc.
- Built-in extensions: resources/app/extensions/

Before: <REDACTED: user-file-path>:144:145516
After: <REDACTED: user-file-path>/.vscode/extensions/ms-python.python/out/extension.js:144:145516
Copilot AI review requested due to automatic review settings February 4, 2026 01:17
@vs-code-engineering vs-code-engineering bot added this to the February 2026 milestone Feb 4, 2026
Copy link
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

Updates telemetry path anonymization so extension host callstacks retain the VS Code extension-relative portion of paths (extension id + in-extension file path) while still redacting user-specific parent directories.

Changes:

  • Extend anonymizeFilePaths to detect VS Code user/built-in extension path patterns and preserve the extension-relative suffix.
  • Add telemetry tests asserting user/built-in extension callstack paths are retained while parent directories are redacted.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/vs/platform/telemetry/common/telemetryUtils.ts Detects VS Code extension paths during stack scrubbing and preserves the extension-relative portion while redacting parent directories.
src/vs/platform/telemetry/test/browser/telemetryService.test.ts Adds coverage for extension-path preservation in unexpected error telemetry callstacks.
Comments suppressed due to low confidence (1)

src/vs/platform/telemetry/common/telemetryUtils.ts:339

  • The preserved extension path is reattached using a hardcoded '/', which can produce mixed separators for Windows paths (e.g. <REDACTED...>/.vscode\extensions\...) and may reduce usefulness for diagnostics. Consider normalizing the retained segment to forward slashes (or reusing the original separator) and avoid unconditional '/' insertion if the retained segment already starts with a separator.
			if (vscodeExtMatch) {
				// Keep ".vscode[-variant]/extensions/extension-name/..." but redact the parent folder
				updatedStack += stack.substring(lastIndex, result.index) + '<REDACTED: user-file-path>/' + vscodeExtMatch[2];
			} else {
				updatedStack += stack.substring(lastIndex, result.index) + '<REDACTED: user-file-path>';

// 1. User extensions: .vscode/extensions/, .vscode-insiders/extensions/, .vscode-server/extensions/, etc.
// 2. Built-in extensions: resources/app/extensions/
// Capture everything from the vscode folder or resources/app/extensions onwards
const vscodeExtensionsPathRegex = /^(.*?)((?:\.vscode(?:-[a-z]+)?|resources[\\\/]app)[\\\/]extensions[\\\/].*)$/i;
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

vscodeExtensionsPathRegex only allows a single -<variant> suffix (e.g. .vscode-server), so it won’t match real folder names like .vscode-server-insiders (multiple hyphen segments). This will cause server-insiders extension callstacks to be fully redacted. Consider allowing multiple suffix segments (e.g. \.vscode(?:-[a-z]+)*) or a more general \.vscode(?:-[\w]+)* before /extensions/.

Suggested change
const vscodeExtensionsPathRegex = /^(.*?)((?:\.vscode(?:-[a-z]+)?|resources[\\\/]app)[\\\/]extensions[\\\/].*)$/i;
const vscodeExtensionsPathRegex = /^(.*?)((?:\.vscode(?:-[\w]+)*|resources[\\\/]app)[\\\/]extensions[\\\/].*)$/i;

Copilot uses AI. Check for mistakes.
Comment on lines +64 to +66
public builtinExtensionPathToRetain: string = 'resources/app/extensions/git/out/git.js:42:1234';
public fullBuiltinExtensionPath: string = '/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/out/git.js:42:1234';
public anonymizedBuiltinExtensionPath: string = '<REDACTED: user-file-path>/resources/app/extensions/git/out/git.js:42:1234';
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

The built-in extension test data uses .../Contents/Resources/app/... (capital R), but builtinExtensionPathToRetain/anonymizedBuiltinExtensionPath expect resources/app/... lowercase. Since the regex match preserves the original casing, these assertions can fail depending on the input path. Align the test expectations with the provided fullBuiltinExtensionPath, or normalize the preserved built-in path to a canonical resources/app/extensions/... form in the implementation and update the expectations accordingly.

Suggested change
public builtinExtensionPathToRetain: string = 'resources/app/extensions/git/out/git.js:42:1234';
public fullBuiltinExtensionPath: string = '/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/out/git.js:42:1234';
public anonymizedBuiltinExtensionPath: string = '<REDACTED: user-file-path>/resources/app/extensions/git/out/git.js:42:1234';
public builtinExtensionPathToRetain: string = 'Resources/app/extensions/git/out/git.js:42:1234';
public fullBuiltinExtensionPath: string = '/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/out/git.js:42:1234';
public anonymizedBuiltinExtensionPath: string = '<REDACTED: user-file-path>/Resources/app/extensions/git/out/git.js:42:1234';

Copilot uses AI. Check for mistakes.
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.

3 participants