Skip to content

fix(cli): reject an open range missing its end instead of scanning zero targets - #773

Merged
kaifcodec merged 2 commits into
kaifcodec:mainfrom
lee3Q:fix/lenset-open-range
Nov 7, 2026
Merged

kaifcodec merged 2 commits into
kaifcodec:mainfrom
lee3Q:fix/lenset-open-range

Conversation

@lee3Q

@lee3Q lee3Q commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Problem

Length-set syntax supports closed ranges like {2-4}. Two incomplete forms are mishandled today:

  • test[a-c]{2-} — the dash is consumed but the range has no end. The lenset silently comes out empty, so the pattern expands to zero permutations and the scan runs on no targets without any error (it just reports nothing found). The mirror form {-2} already raises a parse error, so {2-} slipping through quietly is inconsistent.
  • {2-;3} — the malformed part is silently dropped and only {3} is scanned.

Fix

In _parse_lenset, when the - was consumed but no range end follows, raise ValueError('Missing range end after "-" in lenset') instead of continuing with an empty/partial lenset. This is the same error class as the existing {-2} rejection. All finite forms ({3}, {2-4}, mixed lists) parse exactly as before.

Testing

  • New regression test test_error_open_range_missing_end: on main the expression expands to zero permutations silently; with the fix it raises the ValueError.
  • Full suite: 516 passed on Python 3.10 (515 baseline + 1 new), repo-pinned mcp<2, ReportLab present. An independent second environment observed 511 passed / 4 skipped → 512 passed / 4 skipped (the 4 skips are ReportLab-absent test_pdf_generator.py skips), the same +1 delta. No real handles were scanned and no network calls were made; the test exercises the pure pattern expander.
  • ruff check: the repo carries pre-existing findings on main; the two changed files introduce zero new ones.

lee3Q added 2 commits November 4, 2026 01:11
…ro targets

Added error handling for missing range end in lenset parsing.
Add test for error when open range is missing end.

@kaifcodec kaifcodec left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM.

@kaifcodec
kaifcodec merged commit 31ab250 into kaifcodec:main Nov 7, 2026
2 checks passed
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