Skip to content

fix(cli): emit consensus_threshold=0 in vote list JSON when whitelist is empty#828

Open
ebios-star wants to merge 1 commit intoentrius:testfrom
ebios-star:fix/vote-list-consensus-threshold-empty
Open

fix(cli): emit consensus_threshold=0 in vote list JSON when whitelist is empty#828
ebios-star wants to merge 1 commit intoentrius:testfrom
ebios-star:fix/vote-list-consensus-threshold-empty

Conversation

@ebios-star
Copy link
Copy Markdown
Contributor

Summary

Closes #753.

`gitt vote list --json` (cli/issue_commands/vote.py:248-249) computed `required = (n // 2) + 1` unconditionally, so an empty validator whitelist produced `{"count": 0, "consensus_threshold": 1}` — a 1-of-0 threshold that no integer vote count can satisfy.

JSON consumers (dashboards, monitoring scripts) could not detect the empty-whitelist edge case from this field alone, even though the human-mode branch already prints "No validators whitelisted." and skips the threshold line entirely.

Now: `consensus_threshold == 0` when no validators are whitelisted; the existing `(n // 2) + 1` majority is preserved for non-empty whitelists.

Related Issues

Closes #753.

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other

Testing

  • New `tests/cli/test_vote_list_consensus.py` covers three cases:
    • empty whitelist → `consensus_threshold == 0`
    • 3 validators → `consensus_threshold == 2`
    • 1 validator → `consensus_threshold == 1`
  • `uv run --extra dev pytest tests/` — 446 tests pass (443 baseline + 3 new).

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Changes are documented (if applicable)

… is empty

`gitt vote list --json` (cli/issue_commands/vote.py:248-249) computed
`required = (n // 2) + 1` unconditionally, so an empty validator
whitelist produced `{"count": 0, "consensus_threshold": 1}` — a
1-of-0 threshold that cannot be satisfied by any integer vote count.

Guard the calculation so `consensus_threshold == 0` when no validators
are whitelisted. JSON consumers (dashboards, monitoring scripts) can
now detect the empty-whitelist edge case from the field directly. The
human-mode branch already handles the empty case via the
"No validators whitelisted." path and stays unchanged.

Closes entrius#753.
@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label Apr 28, 2026
@ebios-star
Copy link
Copy Markdown
Contributor Author

@anderdc @LandynDev — friendly ping for review when you have a moment.

Closes #753. When the validator whitelist is empty, gitt vote list --json previously emitted {"count": 0, "consensus_threshold": 1} — a 1-of-0 threshold that no integer vote count can satisfy. JSON consumers (dashboards, monitoring) now see consensus_threshold: 0 for empty whitelists. Existing (n // 2) + 1 majority preserved for non-empty cases. 3 new tests, full test suite passes.

Happy to rebase if needed.

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 vote list --json reports consensus_threshold=1 when validator whitelist is empty

1 participant