Skip to content

fix(validator): tokenize gh-list-no-limit's flag check instead of substring match - #1147

Open
AmirF194 wants to merge 1 commit into
apache:mainfrom
AmirF194:fix/gh-list-limit-comment-bypass
Open

fix(validator): tokenize gh-list-no-limit's flag check instead of substring match#1147
AmirF194 wants to merge 1 commit into
apache:mainfrom
AmirF194:fix/gh-list-limit-comment-bypass

Conversation

@AmirF194

@AmirF194 AmirF194 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • validate_gh_list_limit decides whether a gh issue list / gh pr list call is missing
    --limit by testing whether the literal substring --limit occurs anywhere on the
    logical line, so a trailing shell comment or a quoted argument that merely mentions
    --limit silently suppresses the warning even when the command has no such flag.
  • Fixes it by tokenizing the line with shlex.split(..., comments=True) and checking for an
    actual --limit (or --limit=N) token instead of a bare substring match.

Type of change

  • Python package (tools/*/ with pyproject.toml)

Test plan

  • prek run --all-files passes
  • For Python packages touched: uv run pytest / ruff check / mypy passes
  • Added three cases to TestGhListLimit: a trailing comment containing --limit, a quoted
    argument containing --limit, and the --limit=100 equals-form (control, must stay
    silent). The first two fail on main and pass on this branch, verified both ways on
    Python 3.12. Full tests/test_validator.py (466 cases) still passes.
  • I have not checked every --limit spelling gh itself accepts, only --limit N and
    --limit=N.

RFC-AI-0004 compliance

  • Sandbox: no new host access, pure text processing like the code it replaces

Linked issues

Self-discovered while reading the validator surface; no existing issue.

Notes for reviewers (optional)

_GH_LIST_RE matching and the fenced-block boundary are unchanged. The only touched
function is validate_gh_list_limit, single call site.

…string match

validate_gh_list_limit tested for the literal substring "--limit" anywhere on
the logical line, so a trailing shell comment or a quoted argument that
merely mentions "--limit" silently defeated the check even when the command
had no such flag. Tokenize with shlex.split(comments=True) and match an
actual --limit / --limit=N token instead.

Fixes apache#1146

Generated-by: Claude Code (Sonnet 5)
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.

1 participant