fix(cli): validate --repo filter on gitt issues list (#1061) - #1112
Closed
RUNECTZ33 wants to merge 9 commits into
Closed
fix(cli): validate --repo filter on gitt issues list (#1061)#1112RUNECTZ33 wants to merge 9 commits into
gitt issues list (#1061)#1112RUNECTZ33 wants to merge 9 commits into
Conversation
Co-authored-by: Ander <61125407+anderdc@users.noreply.github.com>
Co-authored-by: mkdev11 <MkDev11@users.noreply.github.com>
…t and ScoredMirrorPR (entrius#951)
…ntrius#1044) Co-authored-by: anderdc <me@alexanderdc.com>
… paths (entrius#897) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Ander <61125407+anderdc@users.noreply.github.com>
…nt event loop starvation (entrius#945) Co-authored-by: Ander <61125407+anderdc@users.noreply.github.com>
…ig (entrius#935) Co-authored-by: shadeform <shadeform@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
The `--repo <owner/name>` filter added in entrius#910 compares raw user input directly against `repository_full_name`, so: - malformed inputs like `ownerrepo` or `owner//repo` are silently accepted and quietly match nothing (no error to the user); - whitespace-padded valid inputs like `' entrius/gittensor '` fail to match real entries because the comparison string still contains the surrounding spaces. Fix by reusing the existing `validate_repository(verify_exists=False)` helper before any contract read, normalizing `repo_filter` to a clean `owner/repo` string and surfacing `click.BadParameter` through the existing `handle_exception` path so JSON consumers get a structured `bad_parameter` error and human callers exit non-zero. This is the same validator already used by `gitt issues register/cancel` mutating commands, so the read-side `--repo` filter now matches the documented contract enforced everywhere else. ## Tests - Malformed filters (`ownerrepo`, `owner//repo`, `owner/`, `/repo`, `owner repo`) rejected with structured `bad_parameter` error in JSON mode and non-zero exit in human mode, before any contract read. - Whitespace-padded valid filter `' owner/repo '` correctly matches the contract entry and returns the issue. - Mixed-case filter `OWNER/REPO` still matches (preserves existing case-insensitive behavior). - Valid non-matching filter returns empty list rather than all issues. Closes entrius#1061
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1061.
Problem
--repo <owner/name>ongitt issues list(added in #910) compares raw user input directly againstrepository_full_name:So:
ownerrepoorowner//repoare silently accepted and quietly match nothing (no error feedback).' entrius/gittensor 'fail to match real entries because the comparison string still contains the surrounding spaces.Fix
Reuse the existing
validate_repository(verify_exists=False)helper before any contract read. It already:owner/reporegex,click.BadParameterwithparam_hint='--repo'on bad input.Surface that exception through the existing
handle_exceptionpath so JSON consumers get a structuredbad_parametererror and human callers exit non-zero — same shape used by--idvalidation a few lines above.The same validator is already used by mutating commands (
gitt issues register/cancelinmutations.py), so the read-side--repofilter now matches the documented contract enforced everywhere else in the CLI.Tests added
6 new tests in
tests/cli/test_issues_list_json.py:bad_parametererror in JSON mode (parametrized overownerrepo,owner//repo,owner/,/repo,owner repo).' owner/repo 'correctly matches contract entries.OWNER/REPOstill matches (preserves existing case-insensitive behavior).All tests pass;
read_issues_from_contractis asserted not-called for invalid input so we never burn a contract read on bad parameters.Diff size
gittensor/cli/issue_commands/view.py: +12 lines (1 import + 8-line validation block + 1-line comment)tests/cli/test_issues_list_json.py: +95 lines (6 new tests)