{"id":"XE-0057","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"77","source_url":"https://github.com/xeprotocol/xe/issues/77","reporter_id":25,"title":"api/openapi: node errors are {\"error\": string} but every response schema is the object Error shape; the SDK in turn drops proxy error messages (Medium)","area":"sdk-docs-web","claimed_tier":"medium","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":true,"internal_ref":"","internal_url":null,"status":"accepted","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-29T13:57:19.866928+00:00","updated_at":"2026-11-10T11:38:19.569974+00:00","source_created_at":"2026-10-26T20:21:08+00:00","told_at":"2026-11-10T00:15:35+00:00","status_changed_at":"2026-10-29T14:04:12.620578+00:00","url":"https://bounty.xe.network/XE-0057","body":"- Suggested tier: Medium (\"inconsistent API responses\"), Minor if the team counts it as docs only\n- Area: HTTP API error model, OpenAPI document, SDK\n- Found: 2026-10-26, node `xe/92d83d1`, openapi.json 1.0.0, SDK master `0dbc92e`\n\n## Summary\n\nThe API returns two different error shapes and clients cannot rely on either:\n\n1. **Node errors** (every 4xx the node itself produces): `{\"error\": \"<string>\"}`.\n2. **Proxy errors** (test.network proxy: unknown route, rate limit, upstream failure): `{\"error\": {\"code\", \"status\", \"message\", \"hint\", \"docs\", ...}}`.\n\nThe OpenAPI document types every 4xx and 5xx response of every operation as `#/components/schemas/Error`, which requires `error` to be an object with `code`, `status`, `message`, `hint` and `docs`. Response descriptions say for example \"`error.code` is `not_found`\". llms.txt says \"Errors are JSON with `error.code`, `error.message` and `error.hint`\". In practice 14 of 15 error responses I sampled through the proxy have a string `error` and fail that schema.\n\nThe `Error` schema description does say upstream JSON bodies pass through unchanged, but the response schemas still reference only `Error`, so any client generated from the OpenAPI document (or written from its descriptions) expects `error.code` and gets `undefined`.\n\nThe official SDK went the other way: it only reads a string `error` (`src/client.ts:195`). Every proxy generated error therefore loses its message and hint and becomes `\"HTTP <status>\"`.\n\n## Evidence\n\nSampled with the Python script below on 2026-10-26 against `https://test.network/api/v1`:\n\n| Request | Status | Body | Matches `Error` schema |\n| --- | --- | --- | --- |\n| `GET /accounts/{funded}/keyset` | 404 | `{\"error\":\"not a multisig account\"}` | no |\n| `GET /blocks/000…0` | 404 | `{\"error\":\"block not found\"}` | no |\n| `GET /leases/000…0` | 404 | `{\"error\":\"lease not found\"}` | no |\n| `GET /vms/000…0` | 404 | `{\"error\":\"vm not found\"}` | no |\n| `GET /certificate` | 404 | `{\"error\":\"no performance certificate\"}` | no |\n| `GET /chat/messages?account=…` | 401 | `{\"error\":\"chat read requires an ownership proof …\"}` | no |\n| `GET /chat/contacts` | 403 | `{\"error\":\"operator endpoint disabled: …\"}` | no |\n| `GET /statechain/blocks/999999999` | 404 | `{\"error\":\"block not found\"}` | no |\n| `GET /statechain/kv/nope.nope` | 404 | `{\"error\":\"key not found\"}` | no |\n| `GET /directory/000…0` | 404 | `{\"error\":\"account not found in directory\"}` | no |\n| `POST /blocks/send` with `{}` | 400 | `{\"error\":\"block type mismatch\"}` | no |\n| `POST /blocks/burn` with `{}` | 400 | `{\"error\":\"block type mismatch\"}` | no |\n| `GET /no/such/route` | 404 | `{\"error\":{\"code\":\"not_found\",\"status\":404,\"message\":…,\"hint\":…}}` | yes |\n\nSDK, one real request: `new XeClient({ url: \"https://test.network/api/v1\", retries: 0 }).request(\"/no/such/route\")`\n\n```\nSDK message : \"HTTP 404\"\nserver body : {\"error\":{\"code\":\"not_found\",\"status\":404,\"message\":\"No API route at /api/v1/no/such/route.\",\"hint\":\"No route matches …\", …}}\n```\n\nSDK code (`src/client.ts:195`):\n\n```ts\nconst message = typeof rec['error'] === 'string' ? rec['error'] : `HTTP ${res.status}`\n```\n\n## Impact\n\n- Clients built from the OpenAPI document mis-handle every node error (no `code`, no `hint`).\n- SDK users lose the message and hint of every proxy error: rate limits, upstream timeouts, unknown routes. Combined with #76, a proxy 429 surfaces as a bare non retryable \"HTTP 429\".\n- No fund risk.\n\n## Suggested fix\n\n1. Either wrap node errors in the `Error` shape at the proxy, or make each response schema `oneOf: [Error, NodeError]` with `NodeError = {error: string, retryable?: boolean}` and fix the descriptions and llms.txt.\n2. In the SDK, read `error.message` (and keep `error.code` / `error.hint`) when `error` is an object.\n\n## PoC script (samples the error bodies, about 15 requests)\n\n```python\n# Call error paths on the test.network proxy and check each body against the OpenAPI Error schema.\nimport json, time, urllib.request, urllib.error\nB = \"https://test.network/api/v1\"\nA = \"f90fa8799733cf1b6dd77c5f1152a4942f73f5c108445085c34fad2f2b289ccb\"\nZ = \"0\" * 64\nCASES = [(\"GET\", f\"accounts/{A}/keyset\"), (\"GET\", f\"blocks/{Z}\"), (\"GET\", \"blocks/nothex\"), (\"GET\", f\"leases/{Z}\"),\n         (\"GET\", f\"vms/{Z}\"), (\"GET\", \"certificate\"), (\"GET\", f\"chat/messages?account={A}\"), (\"GET\", \"chat/contacts\"),\n         (\"GET\", \"statechain/blocks/999999999\"), (\"GET\", \"statechain/kv/nope.nope\"), (\"GET\", f\"directory/{Z}\"),\n         (\"GET\", \"accounts/nothex/balance\"), (\"GET\", \"no/such/route\"), (\"POST\", \"blocks/send\"), (\"POST\", \"blocks/burn\")]\nREQ = (\"code\", \"status\", \"message\", \"hint\", \"docs\")\nfor m, p in CASES:\n    data = b\"{}\" if m == \"POST\" else None\n    req = urllib.request.Request(f\"{B}/{p}\", data=data, method=m, headers={\"Content-Type\": \"application/json\"})\n    try:\n        with urllib.request.urlopen(req, timeout=25) as r: code, body = r.status, r.read()\n    except urllib.error.HTTPError as e: code, body = e.code, e.read()\n    except Exception as e: code, body = \"ERR\", str(e).encode()\n    try:\n        d = json.loads(body); e = d.get(\"error\") if isinstance(d, dict) else None\n        shape = \"SCHEMA_OK\" if isinstance(e, dict) and all(k in e for k in REQ) else \"STRING_ERROR\" if isinstance(e, str) else \"OTHER\"\n    except Exception: shape = \"NOT_JSON\"\n    print(f\"{m:4} {p[:40]:40} {code} {shape:12} {body[:120].decode(errors='replace')}\")\n    time.sleep(0.2)\n```\n\n## Related\n\n#76 (SDK treats 429 as non retryable) is made worse by this: a proxy 429 reaches SDK users as a bare, non retryable \"HTTP 429\". #69 covers missing address validation, which is a different issue.\n\n## Payout\n\nXE address: `6591eab453dbd93b27e2cd674712f94b42d9e7e4d52980b966fa6da4ccd832dc` (same as #75; please confirm it is valid for the mainnet payout).\n","patch_refs":[],"thread":[{"id":1564,"source":"github","source_ref":"6755090557","author":"XE desk","team":true,"body":"Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is\nupdated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0057.","created_at":"2026-11-10T00:15:35+00:00"}]}