fix(cli): issues submissions --json reports empty success when GITTENSOR_MINER_PAT is unset - #1649
Open
michiot05 wants to merge 1 commit into
Open
fix(cli): issues submissions --json reports empty success when GITTENSOR_MINER_PAT is unset#1649michiot05 wants to merge 1 commit into
michiot05 wants to merge 1 commit into
Conversation
…--json instead of empty success
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 issues submissions --id N --jsonreportssuccess: true, submission_count: 0whenGITTENSOR_MINER_PATis not set — even though the GitHub lookup never ran.#1554 (for #1492) made the GraphQL lookup-failure path an explicit error instead of a silent empty success. The missing-token path still falls through to the same false negative, and only in the mode aimed at automation:
fetch_open_issue_pull_requests(gittensor/cli/issue_commands/helpers.py:264) prints the "No GitHub token found" warning only whennot as_json— JSON mode gets no signalfind_prs_for_issue(..., token=None), which returns[]by design for a falsy token (documented as the precondition-not-met case, distinct from theNonefailure sentinel — that contract is unchanged here)submissions.py, onlyNoneis special-cased, so the[]flows intosuccess: true, submission_count: 0Production scenario: monitoring/automation runs
gitt issues submissions --id N --jsonin an environment withoutGITTENSOR_MINER_PAT(read-only setups that never posted a PAT). It concludes the bounty issue has no open submissions when in reality nothing was looked up. Human mode at least prints a warning;--jsonmode is completely silent.Fix: in JSON mode, a missing token now raises
click.UsageError, which the existing handler maps to the canonical error envelope (error.type: "usage_error") with exit 1. This mirrorsgitt miner post --json, which already refuses to run without a PAT ("required for JSON mode",miner_commands/post.py:93). Human mode is untouched (warn and continue).find_prs_for_issue's documented falsy-token →[]contract is untouched.Related Issues
Completes the false-negative elimination started in #1554 (#1492) for the remaining silent path.
Type of Change
Before / After
Reproduced with the contract reads stubbed and
GITTENSOR_MINER_PATunset; the GitHub-lookup CLI path is real.Before — lookup never ran, reported as a successful empty result:
After — explicit error envelope, non-zero exit:
Human mode (no
--json) is unchanged: prints the existing "No GitHub token found; set GITTENSOR_MINER_PAT..." warning and continues to "No open submissions available", exit 0. With a token set, both modes behave exactly as before.Testing
Two tests added in
tests/cli/test_issue_submission.py: JSON mode with the env var unset →success: false,error.type == "usage_error", non-zero exit; human mode with the env var unset → warning preserved, exit 0. Full suite:uv run pytest— 962 passed;uv run pre-commit run --all-files --hook-stage pre-push(ruff, pyright, vulture, pytest) — all green.Checklist