Skip to content

Commit c5e3ddb

Browse files
d-csclaude
andcommitted
fix(webapp): nullish check on synth-span metadata + tighten tags vs runTags test
Two CodeRabbit findings on PR #3755: 1. `buildSyntheticSpanRun` was using `run.metadata ? prettyPrintPacket(...) : undefined`. The truthy check drops `""` (and any other intentionally-empty packet), even though the payload branch above already uses a nullish check and preserves empty-string payloads. Align the two branches with `typeof !== "undefined" && !== null` so empty metadata renders consistently. 2. The "forwards runTags from the snapshot tags array" assertion in `mollifierSynthesiseFoundRun.test.ts` used the same value for `tags` and `runTags` in its fixture. That would silently pass if `synthesiseFoundRunFromBuffer` accidentally read `runTags` instead of `tags`. Use distinct values so the assertion actually locks the mapping down. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7beea9a commit c5e3ddb

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

apps/webapp/app/v3/mollifier/syntheticSpanRun.server.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,16 @@ export async function buildSyntheticSpanRun(args: {
4141
? await prettyPrintPacket(run.payload, run.payloadType ?? undefined)
4242
: undefined;
4343

44-
const metadata = run.metadata
45-
? await prettyPrintPacket(run.metadata, run.metadataType, {
46-
filteredKeys: ["$$streams", "$$streamsVersion", "$$streamsBaseUrl"],
47-
})
48-
: undefined;
44+
// Nullish check, not truthy — matches the payload branch above so an
45+
// intentionally-empty packet (e.g. metadata: "") still gets handed to
46+
// `prettyPrintPacket` and renders consistently. A truthy check would
47+
// drop the empty-string case and the two paths would diverge.
48+
const metadata =
49+
typeof run.metadata !== "undefined" && run.metadata !== null
50+
? await prettyPrintPacket(run.metadata, run.metadataType, {
51+
filteredKeys: ["$$streams", "$$streamsVersion", "$$streamsBaseUrl"],
52+
})
53+
: undefined;
4954

5055
const idempotencyShape = {
5156
idempotencyKey: run.idempotencyKey ?? null,

apps/webapp/test/mollifierSynthesiseFoundRun.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,18 @@ describe("synthesiseFoundRunFromBuffer", () => {
194194
});
195195

196196
it("forwards runTags from the snapshot tags array", () => {
197+
// Use distinct values for `tags` and `runTags` so the assertion
198+
// actually pins the mapping. With the fixture's previous
199+
// `runTags` default matching the same `["alpha", "beta"]` input,
200+
// this test would have passed even if synthesiseFoundRunFromBuffer
201+
// accidentally read `runTags` instead of `tags`.
197202
const found = synthesiseFoundRunFromBuffer(
198-
makeSyntheticRun({ tags: ["alpha", "beta"] })
203+
makeSyntheticRun({
204+
tags: ["from-tags"],
205+
runTags: ["stale-run-tags"],
206+
})
199207
);
200-
expect(found.runTags).toEqual(["alpha", "beta"]);
208+
expect(found.runTags).toEqual(["from-tags"]);
201209
});
202210

203211
it("pins engine to V2 and taskEventStore to taskEvent (only valid values for a buffered run)", () => {

0 commit comments

Comments
 (0)