fix: hub_json/_hub_api silently discarded top-level JSON array responses (musehub#213)
HttpTransport.hub_json() returned {} for any endpoint whose response body is a top-level JSON array -- no error, no warning, exit 0, indistinguishable from 'genuinely empty'. GET /api/mists/{id}/forks hit this directly: a real, non-empty fork list silently became {}. run_forks() already had an (unreachable) isinstance(data, list) fallback for this exact case -- the transport layer just never let it through.
Found the identical bug duplicated independently in hub/cli/commands/hub/_core.py::_hub_api -- a separate implementation (raw urllib, not HttpTransport) used by every issues/proposals/labels/ releases/repos/collaborators/attestations command, with the exact same 'return parsed if isinstance(parsed, dict) else {}' coercion. No current endpoint behind that path returns a bare array today, but the next one that does would hit this exact silent-discard bug again.
Fixed both: arrays now pass through unchanged. A genuinely unexpected top-level shape (a bare scalar) still fails loudly rather than being treated as empty -- transport.py raises TransportError; hub/_core.py keeps its existing {} soft-fail for that narrow case, consistent with its established error-handling style.
Semantic Changes
11 symbols
Files Changed
~5
1260 in snapshot
0 comments
muse hub commit comment sha256:79f4db56b7cc6e6b546dca4a33bfcf134e38a638da584646bf9bb3d057bdb113 --body "your comment"
No comments yet. Be the first to start the discussion.