Skip to content

Commit f6c96ce

Browse files
committed
fix(cli): redact env vars from attempt debug logs (#3566)
1 parent 14824b0 commit f6c96ce

4 files changed

Lines changed: 41 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
Task environment variable values are no longer included in attempt debug logs.

packages/cli-v3/src/entryPoints/managed/execution.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { type SnapshotState, SnapshotManager } from "./snapshot.js";
2525
import type { SupervisorSocket } from "./controller.js";
2626
import { RunNotifier } from "./notifier.js";
2727
import type { TaskRunProcessProvider } from "./taskRunProcessProvider.js";
28+
import { getWorkloadRunAttemptStartLogData } from "./runAttemptLogData.js";
2829

2930
class ExecutionAbortError extends Error {
3031
constructor(message: string) {
@@ -447,7 +448,9 @@ export class RunExecution {
447448
podScheduledAt: this.podScheduledAt?.getTime(),
448449
});
449450

450-
this.sendDebugLog("started attempt", { start: start.data });
451+
this.sendDebugLog("started attempt", {
452+
start: getWorkloadRunAttemptStartLogData(start.data),
453+
});
451454

452455
return { ...start.data, metrics };
453456
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { describe, expect, it } from "vitest";
2+
import { getWorkloadRunAttemptStartLogData } from "./runAttemptLogData.js";
3+
4+
describe("getWorkloadRunAttemptStartLogData", () => {
5+
it("omits environment variable values from the debug-log payload", () => {
6+
const start = {
7+
run: { friendlyId: "run_123" },
8+
snapshot: { friendlyId: "snapshot_123" },
9+
execution: { id: "execution_123" },
10+
envVars: { API_KEY: "secret-value" },
11+
};
12+
13+
expect(getWorkloadRunAttemptStartLogData(start)).toEqual({
14+
run: start.run,
15+
snapshot: start.snapshot,
16+
execution: start.execution,
17+
});
18+
});
19+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
type WorkloadRunAttemptStartData = {
2+
run: unknown;
3+
snapshot: unknown;
4+
execution: unknown;
5+
envVars: Record<string, string>;
6+
};
7+
8+
export function getWorkloadRunAttemptStartLogData<T extends WorkloadRunAttemptStartData>(
9+
start: T
10+
): Pick<T, "run" | "snapshot" | "execution"> {
11+
const { run, snapshot, execution } = start;
12+
return { run, snapshot, execution };
13+
}

0 commit comments

Comments
 (0)