Skip to content

refactor(cli): validate inputs with Click types at parse time#1168

Closed
tao-hunter wants to merge 2 commits into
entrius:testfrom
tao-hunter:cli/click-native-validators
Closed

refactor(cli): validate inputs with Click types at parse time#1168
tao-hunter wants to merge 2 commits into
entrius:testfrom
tao-hunter:cli/click-native-validators

Conversation

@tao-hunter
Copy link
Copy Markdown

Summary

Refactors issue/admin/vote/miner CLI validation to use Click’s built-in types (IntRange, Choice, custom ParamType for bounty/SS58) so bounds and allowed values are enforced at parse time and show correctly in --help. Removes require_valid_issue_id / require_valid_ss58. StyledCommand maps parse-time BadParameter to JSON when --json is present in the subcommand args. issues register runs strict GitHub checks before RPC/config resolution. Adds CLI_NETWORK_NAMES from NETWORK_MAP, validates gitt config set network, and tightens gitt miner check/post --network with Choice.

Related issues

Closes #1154

Type of change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other

Testing

  • Tests updated (tests/cli/test_cli_helpers.py, test_config_set.py, test_issues_list_json.py, test_cli_json_error_output.py)
  • pytest tests/cli/ (excluding test_miner_score / test_cli_json_error_output where substrateinterface is absent): 135 passed, 2 skipped
  • Manual: gitt issues list --help, gitt admin set-owner --help, bad --id / --bounty / --network with and without --json

Checklist

  • Code style consistent with project
  • Self-review done
  • Documentation updated where needed

tao-hunter and others added 2 commits May 12, 2026 03:26
- Add ONCHAIN_ISSUE_ID_TYPE, GITHUB_ISSUE_NUMBER_TYPE, BountyAlphaParam, and
  Ss58AddressParam; derive NETWORK_CHOICE from CLI_NETWORK_NAMES in constants.
- Wire admin, vote, list, submissions, and register/harvest options to these
  types; drop require_valid_* helpers.
- StyledCommand.make_context catches BadParameter when --json is in the
  subcommand argv so structured bad_parameter errors still go to stdout.
- Reorder issues register to run strict GitHub checks before RPC resolution;
  bounty/issue bounds are enforced by Click before any side effects.
- Tighten gitt config set network values; miner check/post --network uses Choice.
- Fix tests to patch vote/admin modules via importlib and relax assertions
  for IntRange messages; skip substrate-heavy tests when optional deps absent.

Co-authored-by: Cursor <cursoragent@cursor.com>
@xiao-xiao-mao xiao-xiao-mao Bot added the refactor Code restructuring without behavior change label May 12, 2026
@anderdc
Copy link
Copy Markdown
Collaborator

anderdc commented May 13, 2026

#1155 is better scoped and implemented. Closing.

@anderdc anderdc closed this May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code restructuring without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace custom validators with Click primitives

2 participants