diff --git a/.changeset/redact-attempt-debug-env.md b/.changeset/redact-attempt-debug-env.md new file mode 100644 index 00000000000..4a1bc8a2e41 --- /dev/null +++ b/.changeset/redact-attempt-debug-env.md @@ -0,0 +1,5 @@ +--- +"trigger.dev": patch +--- + +Task environment variable values are no longer included in attempt debug logs. diff --git a/packages/cli-v3/src/entryPoints/managed/execution.ts b/packages/cli-v3/src/entryPoints/managed/execution.ts index c5bb4875bce..54cf37f6311 100644 --- a/packages/cli-v3/src/entryPoints/managed/execution.ts +++ b/packages/cli-v3/src/entryPoints/managed/execution.ts @@ -25,6 +25,7 @@ import { type SnapshotState, SnapshotManager } from "./snapshot.js"; import type { SupervisorSocket } from "./controller.js"; import { RunNotifier } from "./notifier.js"; import type { TaskRunProcessProvider } from "./taskRunProcessProvider.js"; +import { getWorkloadRunAttemptStartLogData } from "./runAttemptLogData.js"; class ExecutionAbortError extends Error { constructor(message: string) { @@ -447,7 +448,9 @@ export class RunExecution { podScheduledAt: this.podScheduledAt?.getTime(), }); - this.sendDebugLog("started attempt", { start: start.data }); + this.sendDebugLog("started attempt", { + start: getWorkloadRunAttemptStartLogData(start.data), + }); return { ...start.data, metrics }; } diff --git a/packages/cli-v3/src/entryPoints/managed/runAttemptLogData.test.ts b/packages/cli-v3/src/entryPoints/managed/runAttemptLogData.test.ts new file mode 100644 index 00000000000..c2ec100dd96 --- /dev/null +++ b/packages/cli-v3/src/entryPoints/managed/runAttemptLogData.test.ts @@ -0,0 +1,19 @@ +import { describe, expect, it } from "vitest"; +import { getWorkloadRunAttemptStartLogData } from "./runAttemptLogData.js"; + +describe("getWorkloadRunAttemptStartLogData", () => { + it("omits environment variable values from the debug-log payload", () => { + const start = { + run: { friendlyId: "run_123" }, + snapshot: { friendlyId: "snapshot_123" }, + execution: { id: "execution_123" }, + envVars: { API_KEY: "secret-value" }, + }; + + expect(getWorkloadRunAttemptStartLogData(start)).toEqual({ + run: start.run, + snapshot: start.snapshot, + execution: start.execution, + }); + }); +}); diff --git a/packages/cli-v3/src/entryPoints/managed/runAttemptLogData.ts b/packages/cli-v3/src/entryPoints/managed/runAttemptLogData.ts new file mode 100644 index 00000000000..740590740ec --- /dev/null +++ b/packages/cli-v3/src/entryPoints/managed/runAttemptLogData.ts @@ -0,0 +1,13 @@ +type WorkloadRunAttemptStartData = { + run: unknown; + snapshot: unknown; + execution: unknown; + envVars: Record; +}; + +export function getWorkloadRunAttemptStartLogData( + start: T +): Pick { + const { run, snapshot, execution } = start; + return { run, snapshot, execution }; +}