Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/redact-attempt-debug-env.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trigger.dev": patch
---

Task environment variable values are no longer included in attempt debug logs.
5 changes: 4 additions & 1 deletion packages/cli-v3/src/entryPoints/managed/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 };
}
Expand Down
19 changes: 19 additions & 0 deletions packages/cli-v3/src/entryPoints/managed/runAttemptLogData.test.ts
Original file line number Diff line number Diff line change
@@ -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,
});
});
});
13 changes: 13 additions & 0 deletions packages/cli-v3/src/entryPoints/managed/runAttemptLogData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
type WorkloadRunAttemptStartData = {
run: unknown;
snapshot: unknown;
execution: unknown;
envVars: Record<string, string>;
};

export function getWorkloadRunAttemptStartLogData<T extends WorkloadRunAttemptStartData>(
start: T
): Pick<T, "run" | "snapshot" | "execution"> {
const { run, snapshot, execution } = start;
return { run, snapshot, execution };
}