refactor: dedupe the 1_000_000 issue-ID bound in cli/issue_commands/helpers.py#873
Conversation
…elpers.py `gittensor/cli/issue_commands/helpers.py` declared the same bound twice inside the same file: - Module-level `MAX_ISSUE_ID = 1_000_000` (used by `validate_issue_id`) - Function-local `MAX_REASONABLE_ISSUE_ID = 1_000_000` inside `_read_issues_from_child_storage` (used as a sanity ceiling on `next_issue_id` reported by the contract) Both checks fire on `> 1_000_000` (the `>=` in `validate_issue_id` and the `>` in the sanity check are intentionally one-off — the user-input cap rejects 1_000_000 itself, the storage cap accepts it). They share the same bound value, so a future change to one cap that forgets the other would silently drift. Drop the local re-declaration and reference the existing module-level `MAX_ISSUE_ID` instead. Comparison operators stay verbatim, so the warn-and-return-empty boundary is preserved. Add `tests/cli/test_read_issues_sanity_bound.py` pinning the boundary: - `next_issue_id == MAX_ISSUE_ID + 1` triggers the sanity gate, returns `[]`, and skips the per-issue childstate RPC loop entirely. - `next_issue_id == MAX_ISSUE_ID` proceeds past the gate (proven by the per-issue rpc_request actually being called).
|
Hi @anderdc @LandynDev — friendly review request whenever you have a moment. Two same-value declarations of the issue-ID upper bound currently live in the same file ( Net: -1 line of source. New Happy to address feedback or rebase if needed. |
Summary
gittensor/cli/issue_commands/helpers.py currently declares the same bound twice inside the same file:
```python
Line 41 — module level, used by validate_issue_id
MAX_ISSUE_ID = 1_000_000
```
```python
Line 787 — function-local, inside _read_issues_from_child_storage
MAX_REASONABLE_ISSUE_ID = 1_000_000
if next_issue_id > MAX_REASONABLE_ISSUE_ID:
console.print(...'unreasonably large'...)
```
Both checks gate on the same value (`1_000_000`); they share intent ("how many on-chain issues do we ever expect?") but live as separate copies in the same module. A future bound change that touches one but not the other silently drifts: `validate_issue_id` would still cap user input at the old value while the storage sanity check warned at the new value, or vice versa.
This PR replaces the function-local constant with the existing module-level `MAX_ISSUE_ID`. Comparison operators are kept verbatim — `validate_issue_id` continues to reject `>= 1_000_000` (max valid input `999_999`) while the storage sanity check continues to warn on `> 1_000_000` — so the existing one-off difference between the two cap semantics is preserved on purpose.
Net: -1 line of source, single source of truth for the bound.
Type of Change
Testing
Checklist