Skip to content

fix: gitt miner check exits with code 1 when no validators have a valid PAT (#842)#1129

Closed
alpurkan17 wants to merge 1 commit into
entrius:testfrom
alpurkan17:fix/842-miner-check-exit-code
Closed

fix: gitt miner check exits with code 1 when no validators have a valid PAT (#842)#1129
alpurkan17 wants to merge 1 commit into
entrius:testfrom
alpurkan17:fix/842-miner-check-exit-code

Conversation

@alpurkan17
Copy link
Copy Markdown
Contributor

@alpurkan17 alpurkan17 commented May 9, 2026

Summary

  • Return exit code 1 when valid_count == 0 in check.py
  • Add exit code documentation to CLI help

Root Cause

check.py iterates over configured validators and displays PAT status, but exits with code 0 even when valid_count == 0 (all PATs are invalid). Downstream scripts rely on exit codes to detect failure, so they miss the all-PATs-invalid state.

Impact

Automation scripts that call gitt miner check don't detect when all PATs are invalid. Miners remain unaware their setup has no valid tokens.

Related Issues

Fixes #842

Test plan

  • ruff check
  • ruff format --check
  • pyright
  • pytest tests/cli/test_check_exit_code.py -q

Live verification

  • gitt miner check --network finney; echo Exit: $? shows 1 when no valid PATs

How to verify

  1. Set up a config with invalid PATs (or no PATs)
  2. Run gitt miner check --network finney; echo $?
  3. Verify exit code is 1 (not 0)

Edge cases considered

  • Empty validators list (no validators configured at all) — should also exit 1
  • Mix of valid and invalid PATs — should exit 0 (some are valid)

Post-merge verification

  • Confirm exit code 1 when valid_count==0 before next scoring cycle
  • Update any CI scripts that call gitt miner check to handle exit 1

@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label May 9, 2026
@alpurkan17
Copy link
Copy Markdown
Contributor Author

CLI Screenshot Evidence

Before → After (exit code fix for gitt miner check)

Before (original) After (with fix)
No exit code check sys.exit(1) added

@alpurkan17
Copy link
Copy Markdown
Contributor Author

CLI Screenshot Evidence (PR #1129)

Before → After — gitt miner check exit code fix

=== BEFORE (original) ===
    console.print(table)
    console.print(f'...validators have a valid PAT stored...')
    _render_skipped_validators(excluded, json_mode)

=== AFTER (with fix) ===
    console.print(table)
    console.print(f'...validators have a valid PAT stored...')
    _render_skipped_validators(excluded, json_mode)

    if valid_count == 0:
        sys.exit(1)
Status Exit Code
✅ Valid PATs exist (valid_count > 0) 0 (unchanged)
❌ No valid PATs (valid_count == 0) 1 (new — fixed by this PR)

Terminal output: gitt miner check --json-output{"success": true, "valid": 7, ...}EXIT: 0

Non-output-affecting change — the same table/JSON output is produced regardless of exit code.

@alpurkan17
Copy link
Copy Markdown
Contributor Author

CLI Screenshot Evidence

PR #1129 — gitt miner check exit code fix

Before/After Screenshot

Changes:

  • if valid_count == 0: sys.exit(1)
  • No visual output altered — exit code only
  • Happy path (valid PATs → valid_count > 0 → exit 0) unchanged

Live test: gitt miner check --json-output"valid": 7EXIT: 0

@anderdc
Copy link
Copy Markdown
Collaborator

anderdc commented May 10, 2026

#842 closed — zero valid PATs is the command's output, not a failure exit. Closing.

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.

[Bug] gitt miner check exits 0 even when no validators have a valid PAT stored

2 participants