From 9d6a707609c6f5d32e8a04067a9311d07bd99576 Mon Sep 17 00:00:00 2001 From: "sentry[bot]" <39604003+sentry[bot]@users.noreply.github.com> Date: Sat, 10 Oct 2026 22:56:10 +0000 Subject: [PATCH] fix(cli): stub transport in telemetry tests to prevent production event leakage --- packages/cli/test/lib/telemetry.test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/cli/test/lib/telemetry.test.ts b/packages/cli/test/lib/telemetry.test.ts index 719e8e03e..e4eac3a16 100644 --- a/packages/cli/test/lib/telemetry.test.ts +++ b/packages/cli/test/lib/telemetry.test.ts @@ -48,6 +48,26 @@ import { withTracingSpan, } from "../../src/lib/telemetry.js"; +// Tests in this file enable the real SDK (initSentry(true) / withTelemetry with +// SENTRY_CLI_NO_TELEMETRY unset), which uses the production SENTRY_CLI_DSN. The +// transport sends via node:http/https, bypassing the global fetch mock in +// preload.ts, so without this stub every captured test fixture (e.g. CLI-299) +// is uploaded to the real CLI Sentry project. Replace it with a no-op transport +// so the full capture pipeline still runs but nothing leaves the process. +vi.mock("../../src/lib/telemetry/zstd-transport.js", async (importOriginal) => { + const actual = + await importOriginal< + typeof import("../../src/lib/telemetry/zstd-transport.js") + >(); + const { createTransport } = await import("@sentry/core"); + return { + ...actual, + makeCompressedTransport: ( + options: Parameters[0], + ) => createTransport(options, () => Promise.resolve({})), + }; +}); + // Snapshot beforeExit listeners before any test calls initSentry(true). // The ProcessSession integration registers an anonymous handler via setupOnce // that has no cleanup mechanism. After all tests, we remove any listeners