fix(cli): fail issues submissions when no PAT is set instead of reporting zero#1593
Open
swengieer0829 wants to merge 2 commits into
Open
fix(cli): fail issues submissions when no PAT is set instead of reporting zero#1593swengieer0829 wants to merge 2 commits into
issues submissions when no PAT is set instead of reporting zero#1593swengieer0829 wants to merge 2 commits into
Conversation
Without GITTENSOR_MINER_PAT the GitHub GraphQL lookup cannot run, so find_prs_for_issue returns [] for the falsy token and `gitt issues submissions` reported success with submission_count=0 -- a false negative indistinguishable from a genuinely empty result, with no diagnostic at all in --json mode. Raise a ClickException so the missing-token precondition surfaces as a proper error in both human and JSON modes, matching the existing None lookup-failure handling (entrius#1554) and the miner post/score PAT guards. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
|
hi please provide before and after screenshots |
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 submissionsreports a false negative whenGITTENSOR_MINER_PATis not set.The command lists open PR submissions for a bountied issue via GitHub's GraphQL API, which requires a PAT. When no token is present,
find_prs_for_issuereturns[]for the falsy token (it cannot query GitHub at all), andsubmissionstreats that empty list as a genuine result — printingsuccess: true, submission_count: 0and exiting0. That is indistinguishable from an issue that really has zero open submissions, and in--jsonmode there is no diagnostic whatsoever (the "No GitHub token found" warning was gated to human mode only).This is exactly the false-negative the command's own code already guards against for the
NoneGitHub-lookup-failure sentinel (added in #1554):The missing-token case is another way the lookup cannot be performed, so it should surface the same way. This change makes
fetch_open_issue_pull_requestsraise aClickExceptionwhen no PAT is set;submissionsalready routesClickExceptionthroughhandle_exception, so the error is surfaced correctly in both human and JSON modes (exit 1). This also matches howgitt miner post/gitt miner scorealready treat a missing PAT, and keeps JSON and human modes in agreement on exit codes (per #724).Before / After
Command (no
GITTENSOR_MINER_PATin the environment):Before — false negative, exit
0:{"success": true, "issue_id": 42, "repository": "owner/repo", "issue_number": 123, "submission_count": 0, "submissions": []}After — surfaced precondition, exit
1:{"success": false, "error": {"type": "cli_error", "message": "A GitHub token is required to list submissions. Set GITTENSOR_MINER_PAT and retry."}}In human mode, the misleading
No open submissions available (...)line is likewise replaced by a clear error and a non-zero exit.Related Issues
Type of Change
Testing
Added two tests to
tests/cli/test_issue_submission.py, mirroring the existingNonelookup-failure tests:test_submissions_json_missing_token_returns_structured_error— assertssuccess: falseand nosubmission_countkey.test_submissions_human_missing_token_errors_instead_of_no_submissions— asserts a non-zero exit and that the misleading "No open submissions available" line is not printed.Both tests fail on the pre-fix code (the command exits
0) and pass with the fix, so they lock the regression.ruff check,ruff format --check, andvultureare all clean on the changed files.Checklist