fix(cli): validate --id range on gitt i list to match sibling commands#855
Open
plind-junior wants to merge 1 commit intoentrius:testfrom
Open
fix(cli): validate --id range on gitt i list to match sibling commands#855plind-junior wants to merge 1 commit intoentrius:testfrom
gitt i list to match sibling commands#855plind-junior wants to merge 1 commit intoentrius:testfrom
Conversation
`gitt i list --id <N>` accepted 0, negative, and out-of-u32-range values and passed them through to on-chain lookup, returning "Issue N not found on-chain". Sibling commands (`i submissions`, `vote solution`, `vote cancel`) already reject these via validate_issue_id and emit a structured "bad_parameter" error. Apply the same gate in issues_list before _resolve_contract_and_network so invalid IDs short-circuit without an RPC round-trip. JSON mode goes through handle_exception(..., 'bad_parameter') for parity with submissions; human mode prints the standard click message and exits non-zero. PR entrius#335's structured not-found path is preserved for valid IDs that simply don't exist on-chain. Issue entrius#210 prescribed this validation across the CLI but listed only mutations.py / vote.py / admin.py — view.py was outside that file scope and was missed by PR entrius#211.
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.
Summary
gitt i list --id <N>accepted0, negative numbers, and out-of-u32-range values and passed them straight through to on-chain lookup, returning a misleading "Issue N not found on-chain" message. Every sibling command using the sameissue_idsemantics (i submissions,vote solution,vote cancel) already rejects these inputs viavalidate_issue_idand emits a structuredbad_parametererror.view.py:issues_listwas the only outlier.Closes the gap left by #210 / PR #211, which prescribed this validation across the CLI but listed only
mutations.py / vote.py / admin.py—view.pywas outside that scope.Type of Change
Reproduction (before this PR)
Verified on
upstream/testHEADd8ba803.After
Why this isn't a duplicate
1 <= value < 1_000_000on all commands that accept an issue ID or number." The issue's file list named onlymutations.py, vote.py, admin.py, so PR feat(cli): harden and polish issue commands #211 honored that scope and didn't touchview.py. This PR closes the leftover gap.nullto a structured{success: false, error: {...}}payload. This PR does not regress that contract: validation rejects at parse time viaclick.BadParameterbefore any contract read; the structured not-found behavior remains for valid IDs that don't exist on-chain (regression-tested below).require_valid_issue_id/validate_issue_idhelpers — already imported and used elsewhere, just not wired intoissues_list.Implementation
gittensor/cli/issue_commands/view.py:issues_list:Mirrors the existing pattern at
submissions.py:57-60. Single gate at function entry; no new helpers, no new constants.Testing
tests/cli/test_issues_list_json.py— 7 new parametric cases plus the 2 existing PR #335 regression tests:--id 0,-1,1000000,99999999999999--id 0,-1,1000000--json{success: false, error: {type: bad_parameter, ...}}, no contract read--id 999(valid, missing)not_foundpath still fires (regression-locked)Ruff lint + format clean on
view.pyand the test file.Scope
i list --idwithi submissions --id,vote solution,vote cancel, andi register --id.Related
view.pygap from gitt cli improvements #210 / PR feat(cli): harden and polish issue commands #211.Fixes #854
Labels
bug