Skip to content

fix(cli): harden gitt issues against crashes on malformed storage/config inputs - #1584

Closed
minion1227 wants to merge 2 commits into
entrius:testfrom
minion1227:minion_issue_crash_hardening
Closed

fix(cli): harden gitt issues against crashes on malformed storage/config inputs#1584
minion1227 wants to merge 2 commits into
entrius:testfrom
minion1227:minion_issue_crash_hardening

Conversation

@minion1227

Copy link
Copy Markdown
Contributor

Summary

Two gitt issues code paths in gittensor/cli/issue_commands/helpers.py raise an unhandled exception on malformed-but-realistic input, aborting the whole command instead of degrading gracefully. Both are fixed to match the surrounding code's own documented/established behavior:

  1. _read_one_issue_from_child_storage ran bytes.fromhex(...) outside the decode try/except. A malformed / odd-length hex payload raises ValueError, which escapes the per-issue guard and aborts the entire gitt issues list scan — even though the docstring states "Decode failures ... return None". Moving the decode inside the existing try honors that contract, so one bad entry is skipped and the rest still list.

  2. resolve_network did config.get('network', '').lower(); the '' default only applies when the key is absent, so a {"network": null} config makes .get return None and None.lower() raises AttributeError, taking down every gitt issues command. Guarded with (config.get('network') or ''), mirroring the existing guard in the sibling miner_commands resolver.

Before → after (both previously crashed):

resolve_network({network: null})   AttributeError: 'NoneType' has no attribute 'lower'  →  ('wss://…finney', 'finney')
_read_one_issue(malformed hex)     ValueError: non-hexadecimal number found in fromhex()  →  None

The second commit is an unrelated one-line ruff format fix to submissions.py (pre-existing --all-files drift on test from the ruff 0.15.12 bump) so this PR's fork CI is green; no behavior change, happy to split it out if preferred.

Related Issues

None — small internal bug fix.

Type of Change

  • Bug fix

Testing

  • Full suite green (956 passed); ruff + pyright clean; pre-commit run --all-files passes.
  • Added test_read_one_issue_returns_none_on_malformed_hex and TestResolveNetworkNullConfig (2 cases) reproducing both crashes and asserting graceful behavior.

Checklist

  • Code follows style guidelines (ruff/pyright clean)
  • Self-review performed
  • Tests added/updated

Two gitt issues paths crash on malformed-but-realistic inputs instead of
degrading gracefully:

- _read_one_issue_from_child_storage ran bytes.fromhex outside the decode
  try/except, so a malformed/odd-length hex payload raised ValueError out
  of the scan loop and aborted all of `gitt issues list`. The docstring
  already promises decode failures return None; move the decode inside the
  try so it is honored.
- resolve_network did config.get('network', '').lower(), which raises
  AttributeError when config.json has "network": null. Guard it with
  (config.get('network') or ''), matching the sibling miner_commands
  resolver that already handles this.
Pre-existing drift on `test`: under the pinned ruff 0.15.12 the split
f-string in issues_submissions collapses onto one line. --all-files
surfaces it on any fork PR. No behavior change.
@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label Jul 5, 2026
@anderdc

anderdc commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

On-chain storage read via childstate_getStorage always returns valid even-length hex when present (the absent case is already guarded), and gitt config only ever writes network as a string — a null network requires hand-editing config.json. Neither the malformed-hex nor the null-network path occurs in normal operation, so both guard inputs that can't arise. The submissions.py change is unrelated formatting. Closing.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants