fix(cli): harden gitt issues against crashes on malformed storage/config inputs - #1584
Closed
minion1227 wants to merge 2 commits into
Closed
fix(cli): harden gitt issues against crashes on malformed storage/config inputs#1584minion1227 wants to merge 2 commits into
minion1227 wants to merge 2 commits into
Conversation
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.
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. |
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
Two
gitt issuescode paths ingittensor/cli/issue_commands/helpers.pyraise 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:_read_one_issue_from_child_storageranbytes.fromhex(...)outside the decodetry/except. A malformed / odd-length hex payload raisesValueError, which escapes the per-issue guard and aborts the entiregitt issues listscan — even though the docstring states "Decode failures ... returnNone". Moving the decode inside the existingtryhonors that contract, so one bad entry is skipped and the rest still list.resolve_networkdidconfig.get('network', '').lower(); the''default only applies when the key is absent, so a{"network": null}config makes.getreturnNoneandNone.lower()raisesAttributeError, taking down everygitt issuescommand. Guarded with(config.get('network') or ''), mirroring the existing guard in the siblingminer_commandsresolver.Before → after (both previously crashed):
The second commit is an unrelated one-line
ruff formatfix tosubmissions.py(pre-existing--all-filesdrift ontestfrom 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
Testing
ruff+pyrightclean;pre-commit run --all-filespasses.test_read_one_issue_returns_none_on_malformed_hexandTestResolveNetworkNullConfig(2 cases) reproducing both crashes and asserting graceful behavior.Checklist