Description (original issue)
In resolve_network, if --network was set but not one of the known keys (finney, test, local), the value was returned as the WebSocket endpoint with network name custom. A typo such as finny instead of finney became the literal connection string finny, causing confusing failures instead of a clear error.
Miner commands used NETWORK_MAP.get(network.lower(), network), so unknown names were forwarded as-is from --network.
Steps to reproduce (historical)
Issue commands: Many commands use Click.Choice for --network, so invalid names were already rejected at parse time. Programmatic calls to resolve_network('finny', None) still hit the old pass-through.
Miner (user-visible):
gitt miner check --network finny (typo) with other options set.
- Previously the client attempted to use
finny as an endpoint.
Expected behavior
Unknown network strings that are not built-in names must either be rejected with a clear message listing valid names, or be accepted only when they look like real endpoint URLs (ws://, wss://, http://, https://). --rpc-url continues to accept arbitrary URLs as the explicit override.
Actual behavior before fix
Unknown network was returned as the endpoint string with no validation.
Resolution
- Added
looks_like_chain_endpoint() in gittensor/utils/network.py (keeps constants.py free of non-constant logic).
resolve_network in gittensor/cli/issue_commands/helpers.py: after map lookup, unknown values must pass looks_like_chain_endpoint(stripped) or raise click.ClickException with finney, local, test, and a hint to pass a full URL.
_resolve_endpoint in gittensor/cli/miner_commands/helpers.py: same rules for miner --network.
- Tests in
tests/cli/test_cli_helpers.py (TestResolveNetwork, TestMinerResolveEndpoint).
Files changed
gittensor/utils/network.py (new)
gittensor/cli/issue_commands/helpers.py
gittensor/cli/miner_commands/helpers.py
tests/cli/test_cli_helpers.py
Environment
- Gittensor CLI, Python 3.x, any OS
Description (original issue)
In
resolve_network, if--networkwas set but not one of the known keys (finney,test,local), the value was returned as the WebSocket endpoint with network namecustom. A typo such asfinnyinstead offinneybecame the literal connection stringfinny, causing confusing failures instead of a clear error.Miner commands used
NETWORK_MAP.get(network.lower(), network), so unknown names were forwarded as-is from--network.Steps to reproduce (historical)
Issue commands: Many commands use
Click.Choicefor--network, so invalid names were already rejected at parse time. Programmatic calls toresolve_network('finny', None)still hit the old pass-through.Miner (user-visible):
gitt miner check --network finny(typo) with other options set.finnyas an endpoint.Expected behavior
Unknown network strings that are not built-in names must either be rejected with a clear message listing valid names, or be accepted only when they look like real endpoint URLs (
ws://,wss://,http://,https://).--rpc-urlcontinues to accept arbitrary URLs as the explicit override.Actual behavior before fix
Unknown
networkwas returned as the endpoint string with no validation.Resolution
looks_like_chain_endpoint()ingittensor/utils/network.py(keepsconstants.pyfree of non-constant logic).resolve_networkingittensor/cli/issue_commands/helpers.py: after map lookup, unknown values must passlooks_like_chain_endpoint(stripped)or raiseclick.ClickExceptionwithfinney,local,test, and a hint to pass a full URL._resolve_endpointingittensor/cli/miner_commands/helpers.py: same rules for miner--network.tests/cli/test_cli_helpers.py(TestResolveNetwork,TestMinerResolveEndpoint).Files changed
gittensor/utils/network.py(new)gittensor/cli/issue_commands/helpers.pygittensor/cli/miner_commands/helpers.pytests/cli/test_cli_helpers.pyEnvironment