{"id":"XE-12545","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":2086,"title":"[Minor] desk: _unwrap raises raw JSONDecodeError on 200 + garbage JSON instead of the documented XeError (XE-1774 residual)","area":"other","claimed_tier":"minor","assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-14T06:27:48.752281+00:00","updated_at":"2026-11-20T19:45:55.676728+00:00","source_created_at":null,"told_at":"2026-11-20T19:45:55.700895+00:00","status_changed_at":"2026-11-20T19:45:55.685755+00:00","url":"https://bounty.xe.network/XE-12545","body":"## Summary\r\n\r\nThe desk client's `_unwrap` guards the error branch (status ≥ 400) but calls `r.json()` unguarded on the success branch — a 200 with garbage JSON raises a raw `json.JSONDecodeError` instead of the documented `XeError`. The DAO copy wraps it in `XeError` (the XE-1774 fix, awarded Minor, DAO-only). The same function also accepts NaN/Infinity/NUL-bearing JSON with no `_parse` refusal, while the DAO `_parse` refuses all of them. This is the 7th \"fix reached one copy only\" pair.\r\n\r\n## Location\r\n\r\n- `desk/xe/client.py:49-57` (`_unwrap` — success branch `return r.json()` unguarded)\r\n- `dao/xe/client.py` (XeError wrap — the XE-1774 fix the desk copy lacks)\r\n- `dao/xe/client.py:138` (`_parse` — refuses NaN/Infinity/NUL/surrogates; the desk copy has no equivalent)\r\n\r\n## Description\r\n\r\n```python\r\n# desk/xe/client.py:49-57 — _unwrap\r\n@staticmethod\r\ndef _unwrap(r: httpx.Response) -> Any:\r\n    if r.status_code >= 400:\r\n        try:\r\n            msg = r.json().get(\"error\", r.text)\r\n        except Exception:\r\n            msg = r.text\r\n        raise XeError(r.status_code, msg)\r\n    if not r.content:\r\n        return None\r\n    return r.json()  # <-- unguarded: garbage JSON on a 200 raises raw JSONDecodeError\r\n```\r\n\r\nThe error branch wraps parse failures; the success branch does not. A 200 with a non-JSON body escapes as a raw `json.JSONDecodeError`, not the `XeError` the client documents.\r\n\r\nPoC (executed, MockTransport): a 200 with body `not json{{` → raw `json.JSONDecodeError`, NOT `XeError`.\r\n\r\nSub-point (same function, same DAO fix family): the desk client also accepts NaN/NUL-bearing JSON with no refusal — `_get(\"/nan\")` returned `{'x': nan}`; a NUL escape returned `'a\\x00b'`. The DAO `_parse` refuses NaN/Infinity/NUL/surrogates.\r\n\r\n## Impact\r\n\r\nError-contract violation: the client's documented error type is `XeError`, and any caller catching `XeError` specifically misses this failure mode. The NaN/NUL leg lets malformed values flow into callers unchecked.\r\n\r\nHonest framing: in-service masking verified — the desk's only caller, `refresh_node` (`desk/desk/context.py:45`), catches broad `Exception`, so in-service this is only a misleading \"node unreachable\" log line. The frame is the shared-library residual (the XE-11872 footing), not a live crash.\r\n\r\n## Reproduction\r\n\r\n1. Mock a 200 response with body `not json{{`.\r\n2. Call any desk client method.\r\n3. Observe a raw `json.JSONDecodeError` instead of `XeError`.\r\n4. (Sub-point) Mock a 200 with body `{\"x\": NaN}` — observe `{'x': nan}` returned, no refusal.\r\n\r\n## Suggested fix\r\n\r\nWrap the success-branch `r.json()` in try/except and raise `XeError`, mirroring the DAO copy; add `_parse`-style refusal of NaN/Infinity/NUL/surrogates in the same place.\r\n\r\n## Not a duplicate\r\n\r\n`q=XE-1774` → 3: XE-1857 (SDK `asBigInt`), XE-7935 (desk size cap + 3xx), XE-9376 (`XeClient` constructor `InvalidURL`) — none is the desk `_unwrap`. `q=_unwrap` → 5, `q=JSONDecodeError` → 3 — none is the desk `_unwrap`. Near-neighbor XE-4592 (DAO `_post_raw` leaks non-XeError) is the DAO copy's REQUEST-side encode error (outgoing body `UnicodeEncodeError`), NOT the desk `_unwrap` RESPONSE-side parse error — distinct site, error, and copy. Checked 2026-11-14. No public ticket files the desk `_unwrap` raw `JSONDecodeError` or its NaN/NUL acceptance.","patch_refs":[],"thread":[{"id":15346,"source":"desk","source_ref":"reply:13237","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-12545 and says what differs; it is read like any other.","created_at":"2026-11-20T19:45:55.676728+00:00"}]}