fix(cli): admin payout-issue reports a successful zero-return payout as failure - #1648
Open
michiot05 wants to merge 1 commit into
Open
fix(cli): admin payout-issue reports a successful zero-return payout as failure#1648michiot05 wants to merge 1 commit into
michiot05 wants to merge 1 commit into
Conversation
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
gitt admin payout-issuereports "Payout failed." and exits 1 for a payout that actually succeeded on-chain, wheneverpayout_bountyreturns0.IssueCompetitionContractClient.payout_bounty(gittensor/validator/issue_competitions/contract_client.py:700) returnsOptional[int]with three shapes:intget_issueread0tx_hash and not error), but the pre-submitget_issueread returnedNone, soexpected_payoutis unknown:return int(expected_payout) if expected_payout else 0NoneThe caller at
gittensor/cli/issue_commands/admin.py:156used a truthiness check (if result:), which collapses the success-with-unknown-amount0into the failure branch.Reachability:
get_issueswallows all exceptions toNone(contract_client.py:229).payout_bountyperforms its ownget_issueread after the CLI has already read and displayed the issue, so a transient RPC failure on that second read — with the extrinsic itself succeeding — yields exactly0. The operator is told the payout failed (exit 1), while the transfer went through; a retry then runs into the contract's already-finalized state (BountyNotCompleted).Fix: the caller-side one-liner —
if result is not None:— as prescribed in the #1577 review. OnlyNone(the genuine failure sentinel) takes the failure branch. No change tocontract_client.py; the sibling admin commands (cancel-issue,set-owner,add-vali,remove-vali,set-treasury) wrapbool-returning client methods, where truthiness is correct — they are untouched.Related Issues
Implements the caller-side fix described by @anderdc in the close comment of #1577.
Type of Change
Before / After
Reproduced by running the real CLI with only the contract client stubbed (
payout_bounty→0, i.e. successful tx with the pre-submit read unavailable):Before — on-chain success reported as failure, exit 1:
After — success reported, exit 0:
Failure path (
payout_bounty→None) is unchanged:✗ Payout failed., exit 1.Testing
Added
TestCliAdminPayoutResult(3 cases: positive int → success,0→ success,None→ failure) exercising the command throughCliRunnerwith the contract client mocked. Full suite:uv run pytest— 963 passed;uv run pre-commit run --all-files --hook-stage pre-push(ruff, pyright, vulture, pytest) — all green.Checklist