-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Preserve VS Code extension paths in telemetry callstacks #292742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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
There was a problem hiding this 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
anonymizeFilePathsto 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; |
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
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/.
| const vscodeExtensionsPathRegex = /^(.*?)((?:\.vscode(?:-[a-z]+)?|resources[\\\/]app)[\\\/]extensions[\\\/].*)$/i; | |
| const vscodeExtensionsPathRegex = /^(.*?)((?:\.vscode(?:-[\w]+)*|resources[\\\/]app)[\\\/]extensions[\\\/].*)$/i; |
| 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
AI
Feb 4, 2026
There was a problem hiding this comment.
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.
| 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'; |
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:
This made it impossible to identify which extension was causing errors.
Solution
The
anonymizeFilePathsfunction now recognizes VS Code extension paths and preserves them:Matches:
.vscode/extensions/,.vscode-insiders/extensions/,.vscode-server/extensions/, etc.resources/app/extensions/After:
The user's home directory is redacted, but the extension name and file path within it are preserved for debugging.
Testing