From da43e2c55d78de04c883aaac811df2cb9fe46c7b Mon Sep 17 00:00:00 2001 From: "vs-code-engineering[bot]" <122617954+vs-code-engineering[bot]@users.noreply.github.com> Date: Mon, 15 Jun 2026 20:41:50 +0000 Subject: [PATCH] fix: validate copilotTelemetryURL in GitHub telemetry sender (fixes #321454) (#321459) * fix: validate copilotTelemetryURL in GitHub telemetry sender (fixes #321454) The applicationinsights Sender throws TypeError: Invalid URL when the copilotTelemetryURL from @vscode/copilot-api is a malformed URL string. The new vscode-extension-telemetry reporter (introduced in #3331) passed it to AppInsightsClientOptions.endpointUrl without validation, unlike the old AzureInsightReporter which guards with URL.canParse(). Mirror that guard so the default endpoint is kept when the URL is invalid. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: use ChatResponsePart action for task_complete summary Co-authored-by: vijayupadya <41652029+vijayupadya@users.noreply.github.com> --------- Co-authored-by: vs-code-engineering[bot] <122617954+vs-code-engineering[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: vijayupadya <41652029+vijayupadya@users.noreply.github.com> --- .../telemetry/vscode-node/githubTelemetrySender.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/extensions/copilot/src/platform/telemetry/vscode-node/githubTelemetrySender.ts b/extensions/copilot/src/platform/telemetry/vscode-node/githubTelemetrySender.ts index a1b393e197e..b5645a5ac8b 100644 --- a/extensions/copilot/src/platform/telemetry/vscode-node/githubTelemetrySender.ts +++ b/extensions/copilot/src/platform/telemetry/vscode-node/githubTelemetrySender.ts @@ -179,7 +179,6 @@ function createGitHubTelemetryReporter( }; const appInsightsOptions: AppInsightsClientOptions = { - endpointUrl: capiClientService.copilotTelemetryURL, commonProperties: commonProps, // Static tag overrides (set once, applied to all events) tagOverrides: { @@ -188,6 +187,14 @@ function createGitHubTelemetryReporter( } }; + // Only override the default endpoint when the telemetry URL is a valid URL. The + // applicationinsights Sender calls `new URL(endpointUrl)` and throws "Invalid URL" + // for malformed values; mirror AzureInsightReporter's guard and keep the default. + const telemetryURL = capiClientService.copilotTelemetryURL; + if (telemetryURL && URL.canParse(telemetryURL)) { + appInsightsOptions.endpointUrl = telemetryURL; + } + // Pass customFetcher to use the extension's fetcher service (handles proxy/cert/fallbacks) const newReporter = new TelemetryReporter( key,