gabriel / muse public
fix BREAKING fix/213-hub-json-array-discard #1 / 1
AI Agent gabriel · 9 hours ago · Oct 22, 2026 · Diff

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.

sha256:79f4db56b7cc6e6b546dca4a33bfcf134e38a638da584646bf9bb3d057bdb113 sha
+4 ~6 −1 symbols
5 changed · 1260 in snapshot files
sha256:106b9dd031f15b3dfb0f030ecfe34f71da0fc64dd939a3e0346025ea3a1f33dd snapshot
+4
symbols added
~6
symbols modified
−1
symbol removed
5
files changed
1260
files in snapshot
0
dead code introduced
Semantic Changes 11 symbols
~ muse/cli/commands/hub/_core.py .py 1 symbol modified
~ muse/cli/commands/mist.py .py 1 symbol modified
~ muse/core/transport.py .py 2 symbols modified
~ tests/test_mist_cli.py .py 2 symbols added, 1 symbol modified
+ test_M1b_hub_api_passes_through_list_response method method test_M1b_hub_api_passes_through_list_response L668–699
+ test_M1c_run_forks_json_renders_real_array method method test_M1c_run_forks_json_renders_real_array L702–736
~ tests/test_transport_hub_json.py .py 2 symbols added, 1 symbol removed, 1 symbol modified
− test_non_dict_json_response_returns_empty_dict method method test_non_dict_json_response_returns_empty_dict L92–96
+ test_list_json_response_returned_as_list method method test_list_json_response_returned_as_list L92–98
+ test_scalar_json_response_raises_transport_error method method test_scalar_json_response_raises_transport_error L100–108
Files Changed
~5
1260 in snapshot
← Older Oldest on fix/213-hub-json-array-discard
All commits
Newer → Latest on fix/213-hub-json-array-discard

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:79f4db56b7cc6e6b546dca4a33bfcf134e38a638da584646bf9bb3d057bdb113 --body "your comment"