Skip to content

Commit eef33e5

Browse files
committed
fix(run-engine): createCancelledRun normalises snapshot.tags
cjson encodes empty Lua tables as `{}`, not `[]`. When the drainer pops a buffered run that was cancelled with no tags ever set, snapshot.tags is an empty object, and `.length === 0` evaluates to undefined → the empty object falls through into Prisma's `runTags:` field. Prisma interprets a plain object on a scalar-list field as a relation update operation (`{ set: [...] }`) and rejects with `Argument 'set' is missing`. The drainer treats this as a terminal failure and marks the buffer entry FAILED, so the PG row never lands. Defensive normalisation: only pass `runTags: snapshot.tags` when it's actually an array with content; pass undefined otherwise. Found while running the Phase F challenge suite cancel scenario.
1 parent fd89156 commit eef33e5

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • internal-packages/run-engine/src/engine

internal-packages/run-engine/src/engine/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,15 @@ export class RunEngine {
511511
workerQueue: snapshot.workerQueue,
512512
isTest: snapshot.isTest,
513513
taskEventStore: snapshot.taskEventStore,
514-
runTags: snapshot.tags.length === 0 ? undefined : snapshot.tags,
514+
// Defensive: the snapshot comes from a cjson-encoded buffer
515+
// payload, where empty Lua tables encode as `{}` not `[]`. If
516+
// the drainer pops a buffered run with no tags, snapshot.tags
517+
// will be an empty object, which Prisma misreads as a relation
518+
// update op. Normalise to a real array (or undefined for the
519+
// empty case).
520+
runTags: Array.isArray(snapshot.tags) && snapshot.tags.length > 0
521+
? snapshot.tags
522+
: undefined,
515523
oneTimeUseToken: snapshot.oneTimeUseToken,
516524
parentTaskRunId: snapshot.parentTaskRunId,
517525
rootTaskRunId: snapshot.rootTaskRunId,

0 commit comments

Comments
 (0)