Skip to content

Commit 7a5a1f1

Browse files
nicktrnTrigger.dev RepoOps
authored andcommitted
fix(core): keep Date values intact through log redaction
Fix `timestamp` and other `Date` fields being logged as `{}` in structured log lines. Mono-RevId: 3a9ec3f16fa49947100e0c6c8593c89aa4f1884b
1 parent 7b84fde commit 7a5a1f1

3 files changed

Lines changed: 16 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/core": patch
3+
---
4+
5+
Fix `timestamp` and other `Date` fields being logged as `{}` in structured log lines.

‎packages/core/src/logger.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ function filterKeys(obj: unknown, keys: Set<string>, depth = 0): any {
313313
return truncateString(obj);
314314
}
315315

316-
if (typeof obj !== "object" || obj === null) {
316+
if (typeof obj !== "object" || obj === null || obj instanceof Date) {
317317
return obj;
318318
}
319319

‎packages/core/test/logger.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,16 @@ describe("SimpleStructuredLogger redaction", () => {
186186
expect(line.harmless).toBe("keep me");
187187
expect(JSON.stringify(line)).not.toContain("should-not-appear");
188188
});
189+
190+
it("serialises Date values as ISO strings instead of walking them as objects", () => {
191+
const logger = new SimpleStructuredLogger("test");
192+
const startedAt = new Date("2026-10-20T12:00:00.000Z");
193+
194+
const line = captureLogLine(() => logger.info("run started", { startedAt }));
195+
196+
expect(line.timestamp).toMatch(/^\d{4}-\d{2}-\d{2}T/);
197+
expect(line.startedAt).toBe("2026-10-20T12:00:00.000Z");
198+
});
189199
});
190200

191201
describe("redact()", () => {

0 commit comments

Comments
 (0)