Skip to content

fix(tier3): report regex compiler limits during preflight - #905

Open
Afloat16 wants to merge 1 commit into
NVIDIA:mainfrom
Afloat16:fix/declarative-preflight-regex-limits-20261126
Open

Afloat16 wants to merge 1 commit into
NVIDIA:mainfrom
Afloat16:fix/declarative-preflight-regex-limits-20261126

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Summary

Dataset preflight catches re.error, but Python's regex compiler can also raise RecursionError, OverflowError, or ValueError for patterns outside its nesting, repetition, or decimal-conversion limits. These exceptions currently escape the checks validator, aborting dataset validation and the coverage summary before later cases can be reported.

Return the existing invalid-pattern diagnostic for these compiler failures. Other checks and dataset entries continue to be validated, and coverage excludes the unusable check instead of failing the whole report. Valid patterns retain Python's regular-expression semantics.

This addresses preflight compilation, which was explicitly outside the scope of #750's runtime matching limits.

Verification

  • All 9 new regressions fail against unchanged upstream with the real compiler exceptions.

  • Declarative preflight, runtime checks, and dataset-coverage modules: 79 passed.

  • Full repository Ruff, changed-file formatting, and diff checks: passed.

  • Isolated wheel and source distribution builds: passed.

  • All three required gates passed for exact contribution c792cd6ec9f9113edf110b53d08670d47a7c995c on a fresh Ubuntu 24.04 runner with Python 3.12.16 and locked all-extra dependencies: validation job. make test reported 45,548 passed, 338 skipped, 19 deselected under the project's existing defaults; no new skips or test exclusions were added.

  • I am familiar with the Contributing Guidelines.

  • Added or updated focused tests.

  • Updated documentation for user-visible changes in the Unreleased changelog.

  • Ran make lint.

  • Ran make test.

  • Ran make build.

  • Did not add credentials, private datasets, or proprietary benchmark content.

Release Impact

  • No user-visible release note needed.
  • Updated CHANGELOG.md.

Signed-off-by: Afloat <ShuffleMonkey@163.com>

@chrisknvidia chrisknvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reproduced all three escapes on main: 2,000-deep nesting raises RecursionError, a{4294967296} raises OverflowError and a repeat count past the int-to-str digit limit raises ValueError, and each one aborts validate_declarative_checks and with it dataset validation and the coverage summary. At head each becomes the normal invalid-pattern diagnostic and the later checks and entries keep being reported. re.compile raises the same types on 3.12, 3.13 and 3.14, so the tuple is right for every supported interpreter.

I ran every output_matches pattern I could find in the repository through the new validator; the only rejections are the two deliberately broken patterns in the existing tests. Compile time stays proportional to pattern length (a 1 MB pattern took about 0.7 s, 100k nested groups fail in a millisecond), so preflight is no less bounded than before. The nine new tests fail on main with the real compiler exceptions and pass at head, and the surrounding declarative-check, coverage, plugin dataset and grader suites show no new failures.

Not blocking, and outside this diff: the runtime worker in _PATTERN_WORKER catches re.error, RecursionError and OverflowError but not ValueError, so the digit-limit pattern comes back as 'the regular expression worker failed' instead of the invalid-pattern reason. With this PR those patterns are rejected before a run, so it only matters for datasets run without preflight, but it would be a one-word follow-up for consistency. DCO signed, lint clean, changelog under Unreleased; the changelog line sits at the same spot as PRs 904, 906 and 907, so the second one to merge needs a trivial rebase.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants