Skip to content

Commit 7a4666e

Browse files
committed
fix(server): keep missing checkpoint errors free of synthetic causes
1 parent ea8aae2 commit 7a4666e

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

‎apps/server/src/orchestration-v2/RunFinalizationService.test.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ it.effect.each(["missing-scope", "read-failure"] as const)(
141141
const threadId = ThreadId.make("thread:finalization-error");
142142
const runId = RunId.make("run:finalization-error");
143143
const scopeId = CheckpointScopeId.make("scope:finalization-error");
144+
const readError = new ProjectionStore.ProjectionStoreReadError({
145+
threadId,
146+
cause: "read failed",
147+
});
144148
const refresh = vi.fn(() => Effect.void);
145149
const layer = RunFinalization.layer.pipe(
146150
Layer.provide(
@@ -150,12 +154,7 @@ it.effect.each(["missing-scope", "read-failure"] as const)(
150154
getCheckpointContext: () =>
151155
scenario === "missing-scope"
152156
? Effect.succeed({ runs: [], checkpointScopes: [], checkpoints: [] })
153-
: Effect.fail(
154-
new ProjectionStore.ProjectionStoreReadError({
155-
threadId,
156-
cause: "read failed",
157-
}),
158-
),
157+
: Effect.fail(readError),
159158
}),
160159
Layer.succeed(RunFinalization.RunFinalizationObserver, {
161160
refresh,
@@ -176,6 +175,7 @@ it.effect.each(["missing-scope", "read-failure"] as const)(
176175
error.operation,
177176
scenario === "missing-scope" ? "missing-checkpoint-scope" : "read-checkpoint-context",
178177
);
178+
assert.strictEqual(error.cause, scenario === "missing-scope" ? undefined : readError);
179179
}
180180
}
181181
assert.equal(refresh.mock.calls.length, 0);

‎apps/server/src/orchestration-v2/RunFinalizationService.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class RunFinalizationError extends Schema.TaggedError<RunFinalizationErro
2222
"missing-checkpoint-scope",
2323
"refresh-workspace",
2424
]),
25-
cause: Schema.Defect(),
25+
cause: Schema.optional(Schema.Defect()),
2626
},
2727
) {}
2828

@@ -81,7 +81,6 @@ const make = Effect.gen(function* () {
8181
return yield* new RunFinalizationError({
8282
...input,
8383
operation: "missing-checkpoint-scope",
84-
cause: `Checkpoint scope ${input.scopeId} was not found after capture.`,
8584
});
8685
}
8786
yield* observer

0 commit comments

Comments
 (0)