Skip to content

fix(cli): honor an explicit --wallet-name default in gitt issues register - #1657

Open
tryeverything24 wants to merge 1 commit into
entrius:testfrom
tryeverything24:fix/register-wallet-flag-resolution
Open

fix(cli): honor an explicit --wallet-name default in gitt issues register#1657
tryeverything24 wants to merge 1 commit into
entrius:testfrom
tryeverything24:fix/register-wallet-flag-resolution

Conversation

@tryeverything24

Copy link
Copy Markdown

PR body — tryeverything24 → entrius/gittensor

Branch: fix/register-wallet-flag-resolution (commit c8a8257, in WSL /root/gtn-pr)

Base: test

Title: fix(cli): honor an explicit --wallet-name default in gitt issues register

Summary

gitt issues register resolves its wallet with a bare string comparison:

effective_wallet = wallet_name if wallet_name != 'default' else config.get('wallet', wallet_name)
effective_hotkey = wallet_hotkey if wallet_hotkey != 'default' else config.get('hotkey', wallet_hotkey)

An explicitly passed --wallet-name default (or --wallet-hotkey default) is
indistinguishable from "no flag given", so when ~/.gittensor/config.json names a different
wallet, the config value silently replaces the wallet the user asked for by name. Register is
the one command in this group that signs an owner-only on-chain transaction with the resolved
wallet's coldkey, so "loaded a different wallet than the one I typed" is the worst place
for this to happen.

The repo already has the correct resolver: resolve_wallet_config in
issue_commands/helpers.py is ParameterSource-aware (an explicit flag wins regardless of
its spelling) and gitt harvest — in this same file — already uses it. Register kept the
pre-helper heuristic.

Reproduction

Against origin/test @ 28c1d4c, with ~/.gittensor/config.json containing
{"wallet": "treasury-cold", "hotkey": "tk"} and all network/GitHub/contract I/O stubbed:

$ gitt issues register --repo o/r --issue 1 --bounty 10 --wallet-name default --hotkey default --yes ...
Loading wallet treasury-cold/tk...        # not the wallet named "default" that was requested

After the fix the same invocation loads default/default; omitting the flags still falls
back to treasury-cold/tk as documented.

Fix

Switch issue_register to the shared resolve_wallet_config (same call shape as harvest)
and drop the now-unused load_config() snapshot. Resolution priority is now genuinely
"explicit CLI flags > config file > defaults" for every spelling of the flags. The
local-network //Alice fallback still triggers on the same effective values as before —
no dev-workflow change.

Tests

New tests/cli/test_register_wallet_resolution.py (config written to a real temp file via a
redirected CONFIG_FILE, wallet construction captured through a stubbed bittensor.Wallet):

  • test_explicit_default_flags_beat_config--wallet-name default with a config wallet
    present loads default/default (fails on current test: loads the config wallet)
  • test_config_fills_in_when_no_flags_given — config wallet/hotkey used when flags omitted
  • test_explicit_named_wallet_beats_config — non-default explicit flags win
  • test_defaults_used_when_no_flags_and_no_config — bare invocation resolves default/default
uv run pre-commit run --files gittensor/cli/issue_commands/mutations.py tests/cli/test_register_wallet_resolution.py   # all hooks Passed
uv run pyright                                                                                                         # 0 errors, 0 warnings
uv run vulture                                                                                                         # clean (exit 0)
uv run pytest tests/ -q                                                                                                # 964 passed

Note: open PR #1650 also touches issue_register, but only the confirmation-gate lines
(confirm_or_abort); this change is a different hunk (wallet resolution, ~15 lines below)
and merges cleanly in either order.

…ster

gitt issues register resolved its wallet with a bare != "default"
comparison, so an explicitly passed --wallet-name default (or
--wallet-hotkey default) was indistinguishable from "no flag given" and
was silently replaced by the config file wallet. A user selecting the
wallet actually named "default" got the config wallet coldkey instead —
on the one command in this group that signs an owner-only on-chain
transaction.

gitt harvest already resolves wallets through resolve_wallet_config,
which is ParameterSource-aware and honors explicit flags regardless of
their spelling. Switch register to the same shared resolution and drop
the now-unused config snapshot. The //Alice local-dev fallback semantics
are unchanged.

Regression tests cover all three resolution tiers: explicit flags
(including flags spelled "default") beat config, config beats defaults,
and defaults apply when neither is present.
@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label Jul 25, 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.

1 participant