fix(cli): don't crash issue commands on a null network in config.json - #1654
Open
rsnetworkinginc wants to merge 1 commit into
Open
fix(cli): don't crash issue commands on a null network in config.json#1654rsnetworkinginc wants to merge 1 commit into
rsnetworkinginc wants to merge 1 commit into
Conversation
resolve_network() reads the config-file fallback with
config.get('network', '').lower(). When ~/.gittensor/config.json contains
"network": null (hand-edited or written by an external tool), the key
exists, so the .get() default is unused, None comes back, and None.lower()
raises AttributeError. _resolve_contract_and_network() calls this on the
startup path of every issue command, so gitt issues/admin/vote commands
all die with a raw traceback instead of falling back.
The miner-side resolver already guards this exact access
(_resolve_endpoint checks `if config_network and ...`), so the two CLIs
currently disagree on the same config file.
Guard the access with (config.get('network') or '') and apply the same
guard to the ws_endpoint fallback label, matching the miner helper.
Add regression tests covering the null-network fallback paths.
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.
PR body — rsnetworkinginc → entrius/gittensor
Branch: fix/issues-cli-null-network (commit d9e0491, in WSL /root/gtn-pr)
Base: test
Title: fix(cli): don't crash issue commands on a null
networkin config.jsonSummary
resolve_network()reads the config-file fallback withWhen
~/.gittensor/config.jsoncontains"network": null(hand-edited, or written by anexternal tool), the key exists, so the
.get()default is never used —Nonecomes backand
None.lower()raisesAttributeError._resolve_contract_and_network()calls this on thestartup path of every issue command, so
gitt issues list,gitt submissions,gitt vote,gitt admin …all die with a raw traceback instead of falling back to the default network.The miner-side resolver already guards this exact access —
miner_commands/helpers.py_resolve_endpointchecksif config_network and config_network.lower() in NETWORK_MAP:— sotoday the two CLIs disagree on the same config file:
gitt miner postworks,gitt issues listcrashes.
Reproduction
After the fix, the same config resolves to the documented default:
$ gitt issues list # resolves to finney default, command proceeds(Repro verified against
origin/test@ f70007c withHOMEpointed at a scratch dir.)Fix
Guard the access with
(config.get('network') or ''), and apply the same guard to thews_endpointfallback label on the line below (config.get('network', 'custom')has the sameNone hole — the network name attached to a custom endpoint would silently become
None).This matches the miner helper's existing behavior, so both resolvers now treat a
null/absent
networkidentically.Tests
New
TestResolveNetworkclass intests/cli/test_cli_helpers.py:test_null_network_falls_back_to_default—{"network": null}→ finney default (crashed before)test_null_network_with_ws_endpoint_uses_endpoint— null network +ws_endpoint→ endpoint withcustomlabel (crashed before)test_recognized_config_network—{"network": "test"}still resolves viaNETWORK_MAPtest_empty_config_falls_back_to_default— no keys → finney default