Fix monitor miners envelope normalization#6786
Conversation
|
CI note for reviewers:
This PR is intentionally scoped to the monitor miners-envelope normalization bug only. |
zqleslie
left a comment
There was a problem hiding this comment.
Code Review Bounty Claim — RustChain PR #6786
Bounty: #73 Code Review Bounty Program
Reviewer: zqleslie
RTC wallet: XKO212dF8324b9b61F294D26A6Dc68e3f81e4BE451D
Reviewed PR
- PR: #6786
- Review state:
APPROVED
Review performed
Reviewed the monitor miners envelope normalization fix:
-
Duplicate function removal — The earlier
normalize_miners_payloadcorrectly handles{items: [...], pagination: ...},{miners: [...]},{data: [...]}, and plain lists. The later duplicate only accepted{miners: [...]}, overwriting the correct one. Removing the duplicate restores proper envelope handling. -
print_miners guard — Changed from
if miners is Nonetoif not isinstance(miners, list). This is safer because the normalizer can return the original dict (e.g.,{"pagination": {"total": 0}}) when there are no miners, and the old check would try to iterate a dict. -
Diff size — +1/-7 in 1 file. Minimal, correct, no side effects.
-
Validation — The inline Python check in the PR body covers the three envelope shapes. No need for local pytest since the function is pure Python with no Flask deps.
No blocking issues found. Safe to merge.
This is a claim only. No payout asserted here.
Fixes a RustChain monitor bug where the correct
/api/minersenvelope normalizer was immediately overwritten by a second narrowernormalize_miners_payloaddefinition.Before:
get_miners()could fetch the current API shape{ "items": [...], "pagination": ... }{ "miners": [...] }tests/test_rustchain_monitor.py::test_request_helpers_call_expected_endpointsfailedWhat changed:
miners,data, anditemsenvelopesprint_minerscheck for a normalized list explicitly before printing rowsValidation:
Local note:
python3 -m pytest tests/test_rustchain_monitor.py -qis blocked in this local environment before reaching the test file becausetests/conftest.pyimports the integrated Flask node and Flask is not installed locally. Hosted CI installs Flask in.github/workflows/ci.yml.