Repository navigation
fix(contract): refuse a list pattern whose element is not a regex #1649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| ### Fixed | ||
|
|
||
| - **A regex a user writes that Python cannot compile is refused, not a traceback.** `re.compile` raises `OverflowError` for a repeat count that does not fit (`a{999999999999}`) and `RecursionError` for groups nested too deep, not the `re.error` the `process_metrics` and contract loaders caught. Those patterns now refuse as bad input (exit 2, `Error: ...`) instead of crashing: a `process_metrics` counter in the repo manifest and a `trace consistency --contract` pattern. | ||
| - **A regex a user writes that Python cannot compile is refused, not a traceback.** `re.compile` raises `OverflowError` for a repeat count that does not fit (`a{999999999999}`) and `RecursionError` for groups nested too deep, not the `re.error` the `process_metrics` and contract loaders caught. A `trace consistency --contract` pattern that triggers either error is refused with exit 2 and `Error: ...`. If a `process_metrics` counter in a repo manifest triggers either error, `eval check` and `repo run` report a manifest error with `✗` and exit 1. | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,8 @@ | ||||||
| <!-- | ||||||
| Copyright (C) 2026 Intel Corporation | ||||||
| SPDX-License-Identifier: Apache-2.0 | ||||||
| --> | ||||||
|
|
||||||
| ### Fixed | ||||||
|
|
||||||
| - **A list of regexes in a `trace consistency --contract` action is checked one element at a time.** The list was joined with `|`, each element wrapped in `(?:...)`, and only the joined pattern was compiled, so `["a)|(?:b"]` was accepted (it joins to two groups) though `a)|(?:b` is not a regex. Each element is now compiled on its own, and a bad one is refused by name as `bad regex`. A list whose elements are each a regex compiles to the same pattern as before. The behaviour change: a list in which one element refers to a group of another (`["(a)", "\1"]`, `["(?P<x>a)", "(?P=x)"]`) is now refused, since that element is not a regex on its own; it was accepted before. The same holds for a list whose elements are each invalid alone but join to a valid pattern (`["(a", "b)"]`): it is now refused. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix before merge (blocking): The changelog says a list whose elements are each a regex compiles as before, but I tested this suggestion: it fixes the problem, and the tests still pass.
Suggested change
DetailsEach element of |
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix before merge (blocking): The changelog says
eval checkexits 1 with✗for a badprocess_metricsregex, buteval check --schema-onlyexits 2 withError:.I tested this suggestion: it fixes the problem, and the tests still pass.
Details
I put
a{999999999999}inprocess_metricsof a manifest and raneval check --schema-only. It printedError: ... process_metrics/bazel: not a valid regex: the repetition number is too largeand exited 2. The plaineval checkandrepo rundo print✗and exit 1, as the sentence says, so the sentence should name the--schema-onlycase too.