Skip to content

Commit 88f2ab4

Browse files
committed
test(formula): use angle-bracket-free regex fixtures for the residual arm (#6223)
`(?<type>` is unquotable in a GitHub issue or PR body: the sanitizer strips `<` followed by a letter as an HTML tag at rest, so the fixture that carries this PR's argument would be destroyed the moment anyone pasted it. `type(` is the same defect with the same native `SyntaxError` (`Invalid regular expression: /type(/: Unterminated group`) and survives the round trip. Adds a `syntax[` fixture for the third keyword while there. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MwoubC3jL271FYt9rGXwxb
1 parent 37cb9fc commit 88f2ab4

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

.changeset/cel-classify-error-by-code.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Two findings from the audit worth recording. First, the residual keyword arm was
4040
**not** dormant: `matches()` is an ObjectStack stdlib binding over `new
4141
RegExp(...)`, so an uncompilable pattern escapes as a native `SyntaxError` whose
4242
message echoes the pattern — and the pattern can come off the row, not just out
43-
of the source. `matches(record.name, record.re)` with `re = "(?<type>"` was
43+
of the source. `matches(record.name, record.re)` with `re = "type("` was
4444
graded `type`; with `"Exceeded maxAstNodes("` it was graded `bounds`. A data
4545
value was picking the error kind. Second, there is deliberately no `TypeError`
4646
arm: cel-js raises that class only from its non-evaluating `TypeChecker`, which

packages/formula/src/cel-engine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ function classifyCelFault(err: unknown): 'parse' | 'bounds' | 'type' | 'runtime'
942942
* `SyntaxError` whose message echoes the pattern (measured, #6223):
943943
*
944944
* ```text
945-
* matches(record.name, "(?<type>") -> type (was)
945+
* matches(record.name, "type(") -> type (was)
946946
* matches(record.name, "Exceeded maxAstNodes(") -> bounds (was)
947947
* matches(record.name, "unexpected(") -> parse (was)
948948
* matches(record.name, record.re) -> type (was) — from a ROW

packages/formula/src/cel-error-classification.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,12 @@ describe('celEngine error classification (#6133)', () => {
269269
// read straight off the record. Before #6223 these four one-and-the-same
270270
// regex failures were graded `type` / `bounds` / `parse` / `type`.
271271
for (const [source, ctx] of [
272-
['matches(record.name, "(?<type>")', { record: { name: 'x' } }],
272+
['matches(record.name, "type(")', { record: { name: 'x' } }],
273273
['matches(record.name, "Exceeded maxAstNodes(")', { record: { name: 'x' } }],
274274
['matches(record.name, "unexpected(")', { record: { name: 'x' } }],
275+
['matches(record.name, "syntax[")', { record: { name: 'x' } }],
275276
// Not even authored: the pattern is a VALUE on the row.
276-
['matches(record.name, record.re)', { record: { name: 'x', re: '(?<type>' } }],
277+
['matches(record.name, record.re)', { record: { name: 'x', re: 'type(' } }],
277278
] as Array<[string, EvalContext]>) {
278279
const { kind, message } = evalKind(source, ctx);
279280
expect(message).toContain('Invalid regular expression');

0 commit comments

Comments
 (0)