Skip to content

Typos in --network were treated as custom RPC/WebSocket URLs instead of validation errors #694

@andriypolanski

Description

@andriypolanski

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):

  1. gitt miner check --network finny (typo) with other options set.
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions