fix: accept zero-length Companion transcripts

This commit is contained in:
2026-09-01 01:41:16 +09:00
parent a9ad42a970
commit 879993b9b1
3 changed files with 31 additions and 1 deletions
@@ -104,6 +104,24 @@ Deno.test("Companion transcript boundary accepts only bounded user-visible items
],
};
assertEquals(parseCompanionTranscriptProjection(fixture), fixture);
assertEquals(
parseCompanionTranscriptProjection({
state: "stopped",
start: 0,
limit: 0,
total: 0,
next: null,
items: [],
}),
{
state: "stopped",
start: 0,
limit: 0,
total: 0,
next: null,
items: [],
},
);
assertThrows(
() =>
@@ -63,7 +63,7 @@ export function parseCompanionTranscriptProjection(
]);
const start = boundedInteger(record.start);
const limit = boundedInteger(record.limit);
if (limit < 1 || limit > MAX_TRANSCRIPT_ITEMS) {
if (limit > MAX_TRANSCRIPT_ITEMS) {
throw new TypeError("Companion transcript limit is out of range");
}
const items = boundedArray(record.items, limit).map(parseTranscriptItem);