Skip to content

Suppress UNC host access errors from unhandled-error telemetry#312236

Open
Copilot wants to merge 5 commits intomainfrom
copilot/suppress-unc-host-access-errors
Open

Suppress UNC host access errors from unhandled-error telemetry#312236
Copilot wants to merge 5 commits intomainfrom
copilot/suppress-unc-host-access-errors

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 23, 2026

Suppresses ERR_UNC_HOST_NOT_ALLOWED errors from being reported as unhandled errors in telemetry. These errors originate from a user-configured allowlist (security.allowedUNCHosts) and represent an expected access denial rather than a bug.

Changes Made

  • src/vs/platform/files/node/diskFileSystemProvider.ts: When mapping a Node.js error to a FileSystemProviderError, treat ERR_UNC_HOST_NOT_ALLOWED as NoPermissions (instead of Unknown) and mark the resulting error as no-telemetry so it does not surface in unhandled-error telemetry.
  • src/vs/base/common/errors.ts: Added a markAsErrorNoTelemetry helper that flags an existing Error instance as no-telemetry while preserving its original class, prototype chain, name, and additional properties. The flag is implemented as an internal __vscodeNoTelemetry property on the error rather than by mutating error.name. This avoids side effects for errors that encode semantics in name — most importantly FileSystemProviderError, whose name carries the FileSystemProviderErrorCode across IPC boundaries. ErrorNoTelemetry.isErrorNoTelemetry checks the new flag and still recognizes the legacy name === 'CodeExpectedError' for compatibility with deserialized errors.
  • src/vs/base/test/common/errors.test.ts: Added a unit test verifying that markAsErrorNoTelemetry preserves the original error class, name, message, and additional properties while making the error detectable as no-telemetry.

Testing

  • ✅ TypeScript compilation passes (npm run compile-check-ts-native)
  • ✅ ESLint passes for the modified files
  • ✅ Unit test added for markAsErrorNoTelemetry

Copilot AI requested review from Copilot and removed request for Copilot April 23, 2026 22:11
Copilot AI changed the title [WIP] Suppress UNC host access errors from Agents error reporting Suppress UNC host access errors from unhandled-error telemetry Apr 23, 2026
Copilot AI requested a review from bryanchen-d April 23, 2026 22:12
@bryanchen-d bryanchen-d marked this pull request as ready for review April 23, 2026 22:24
Copilot AI review requested due to automatic review settings April 23, 2026 22:24
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

This PR aims to prevent UNC host access-denial errors (ERR_UNC_HOST_NOT_ALLOWED)—which result from a user-configured security policy—from being reported as unhandled-error telemetry by marking them as “no telemetry” while also mapping them to a permissions-related file-system error code.

Changes:

  • Map ERR_UNC_HOST_NOT_ALLOWED to FileSystemProviderErrorCode.NoPermissions in DiskFileSystemProvider.toFileSystemProviderError().
  • Introduce markAsErrorNoTelemetry(error) as a helper to mark an existing error instance as “no telemetry” without wrapping it.
  • Add a unit test validating that markAsErrorNoTelemetry preserves the original error instance/type/properties.
Show a summary per file
File Description
src/vs/platform/files/node/diskFileSystemProvider.ts Treat UNC-host-denied as NoPermissions and attempt to suppress telemetry by marking the provider error as no-telemetry.
src/vs/base/common/errors.ts Add markAsErrorNoTelemetry helper that marks an error by mutating its name.
src/vs/base/test/common/errors.test.ts Add test ensuring markAsErrorNoTelemetry preserves instance/type/properties while being detected as no-telemetry.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 3

Comment on lines +883 to +886
const providerError = createFileSystemProviderError(resultError, code);
if (isExpected) {
markAsErrorNoTelemetry(providerError);
}
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

markAsErrorNoTelemetry(providerError) overwrites FileSystemProviderError.name. For file-system errors, the name field is used to carry the FileSystemProviderErrorCode across IPC boundaries (because the IPC channel only serializes message/name/stack for Error instances), and toFileSystemProviderErrorCode() relies on that name format when the error is no longer an actual FileSystemProviderError. With name set to CodeExpectedError, callers in other processes will see this as Unknown (and lose the intended NoPermissions semantics). Consider avoiding name mutation for FileSystemProviderError and instead propagating an explicit no-telemetry marker (e.g. include a noTelemetry/code field in IPC error serialization, or update the no-telemetry mechanism to not repurpose name).

Copilot uses AI. Check for mistakes.
Comment thread src/vs/platform/files/node/diskFileSystemProvider.ts
Comment thread src/vs/base/common/errors.ts
Comment thread src/vs/base/common/errors.ts Outdated
export function markAsErrorNoTelemetry<T extends Error>(error: T): T {
error.name = 'CodeExpectedError';
// eslint-disable-next-line local/code-no-any-casts
(<any>error)[noTelemetryFlag] = true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

instead of any, can we just cast it to a Record<> with the noTelemetryFlag property?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@copilot can you fix this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Replaced the any casts with a typed ErrorWithNoTelemetryFlag = Error & { [noTelemetryFlag]?: boolean } alias used for both setting and reading the flag. Done in 6f3dfaf.

Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/94e6d14a-9e39-41af-b69e-b2a6a715e8d5

Co-authored-by: bryanchen-d <41454397+bryanchen-d@users.noreply.github.com>
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 Telemetry] Suppress UNC host access errors from Agents error reporting

3 participants