Skip to content

Commit db817a3

Browse files
committed
test(service-automation): narrow the defence-in-depth EvalResult pin on its discriminant before reading error
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M59rPZZFzqhfMUPFqqZTkf
1 parent 23b2881 commit db817a3

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

packages/services/service-automation/src/builtin/assignment-value-envelope.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,11 @@ describe('assignment value envelope — one notion of malformed (#15137)', () =>
278278
// Not a path authored metadata can take (both validators and the executor
279279
// run the schema first); kept so the last layer never silently answers a
280280
// value if a future caller bypasses the door.
281-
const result = ExpressionEngine.evaluate({ dialect: 'cel', ast: { op: 'value' } }, {} as never);
282-
expect(result.ok).toBe(false);
283-
expect(result.error?.message).toContain('AST-only evaluation not yet supported');
281+
const result = ExpressionEngine.evaluate({ dialect: 'cel', ast: { op: 'value' } }, {});
282+
// `EvalResult` is a discriminated union — `error` exists only on the
283+
// `ok: false` arm, so narrow on the discriminant before reading it.
284+
if (result.ok) throw new Error('expected the engine to refuse an `ast`-only envelope, got a value');
285+
expect(result.error.message).toContain('AST-only evaluation not yet supported');
284286
});
285287

286288
/**

0 commit comments

Comments
 (0)