From 029aa48aa086fa8de6b3a920dfd715f0ce14add0 Mon Sep 17 00:00:00 2001 From: Les Orchard Date: Mon, 29 Jun 2026 17:49:47 -0700 Subject: [PATCH] test(core): fix flaky image-sanitization logger assertion The "should sanitize image Buffer data in AI_GENERATION messages" test asserted that the serialized log output did not contain the bare string "255" (the 0xff byte value). But the output also includes a Date.now() millisecond timestamp, which intermittently contains the substring "255", failing the test at random (~0.5-1% of CI runs) regardless of whether sanitization worked. Assert against the serialized raw byte sequence ("255,216,255") instead. This matches the actual leak format (a raw byte array) and cannot collide with the timestamp, since a numeric timestamp contains no commas. Co-Authored-By: Claude Opus 4.8 (1M context) --- packages/core/test/loggers.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/core/test/loggers.test.ts b/packages/core/test/loggers.test.ts index 8a2fb44a..30ba9bea 100644 --- a/packages/core/test/loggers.test.ts +++ b/packages/core/test/loggers.test.ts @@ -975,8 +975,10 @@ describe("JSONConsoleLogger", () => { expect(imageBlock.type).toBe("image"); expect(imageBlock.data).toBe(""); expect(imageBlock.size).toBe(fakeJpeg.byteLength); - // Raw byte array must not appear in the output - expect(output).not.toContain("255"); // 0xff byte value + // Raw byte array must not appear in the output. Match the serialized + // byte sequence rather than a bare "255" — the latter collides with + // the millisecond timestamp in the output and makes this test flaky. + expect(output).not.toContain("255,216,255"); // raw fakeJpeg bytes }); it("should preserve raw image data when sanitizeGenerationImages is false", () => {