Bounty
XE-0057 · Bounty

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)

Accepted claimed Medium xe#77 filed 2026-10-26 20:21 UTC by BoomGone

Report

  • Suggested tier: Medium ("inconsistent API responses"), Minor if the team counts it as docs only
  • Area: HTTP API error model, OpenAPI document, SDK
  • Found: 2026-10-26, node xe/92d83d1, openapi.json 1.0.0, SDK master 0dbc92e

Summary

The API returns two different error shapes and clients cannot rely on either:

  1. Node errors (every 4xx the node itself produces): {"error": "<string>"}.
  2. Proxy errors (test.network proxy: unknown route, rate limit, upstream failure): {"error": {"code", "status", "message", "hint", "docs", ...}}.

The 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.

The 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.

The 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>".

Evidence

Sampled with the Python script below on 2026-10-26 against https://test.network/api/v1:

Request Status Body Matches Error schema
GET /accounts/{funded}/keyset 404 {"error":"not a multisig account"} no
GET /blocks/000…0 404 {"error":"block not found"} no
GET /leases/000…0 404 {"error":"lease not found"} no
GET /vms/000…0 404 {"error":"vm not found"} no
GET /certificate 404 {"error":"no performance certificate"} no
GET /chat/messages?account=… 401 {"error":"chat read requires an ownership proof …"} no
GET /chat/contacts 403 {"error":"operator endpoint disabled: …"} no
GET /statechain/blocks/999999999 404 {"error":"block not found"} no
GET /statechain/kv/nope.nope 404 {"error":"key not found"} no
GET /directory/000…0 404 {"error":"account not found in directory"} no
POST /blocks/send with {} 400 {"error":"block type mismatch"} no
POST /blocks/burn with {} 400 {"error":"block type mismatch"} no
GET /no/such/route 404 {"error":{"code":"not_found","status":404,"message":…,"hint":…}} yes

SDK, one real request: new XeClient({ url: "https://test.network/api/v1", retries: 0 }).request("/no/such/route")

SDK message : "HTTP 404"
server body : {"error":{"code":"not_found","status":404,"message":"No API route at /api/v1/no/such/route.","hint":"No route matches …", …}}

SDK code (src/client.ts:195):

const message = typeof rec['error'] === 'string' ? rec['error'] : `HTTP ${res.status}`

Impact

  • Clients built from the OpenAPI document mis-handle every node error (no code, no hint).
  • 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".
  • No fund risk.

Suggested fix

  1. 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.
  2. In the SDK, read error.message (and keep error.code / error.hint) when error is an object.

PoC script (samples the error bodies, about 15 requests)

# Call error paths on the test.network proxy and check each body against the OpenAPI Error schema.
import json, time, urllib.request, urllib.error
B = "https://test.network/api/v1"
A = "f90fa8799733cf1b6dd77c5f1152a4942f73f5c108445085c34fad2f2b289ccb"
Z = "0" * 64
CASES = [("GET", f"accounts/{A}/keyset"), ("GET", f"blocks/{Z}"), ("GET", "blocks/nothex"), ("GET", f"leases/{Z}"),
         ("GET", f"vms/{Z}"), ("GET", "certificate"), ("GET", f"chat/messages?account={A}"), ("GET", "chat/contacts"),
         ("GET", "statechain/blocks/999999999"), ("GET", "statechain/kv/nope.nope"), ("GET", f"directory/{Z}"),
         ("GET", "accounts/nothex/balance"), ("GET", "no/such/route"), ("POST", "blocks/send"), ("POST", "blocks/burn")]
REQ = ("code", "status", "message", "hint", "docs")
for m, p in CASES:
    data = b"{}" if m == "POST" else None
    req = urllib.request.Request(f"{B}/{p}", data=data, method=m, headers={"Content-Type": "application/json"})
    try:
        with urllib.request.urlopen(req, timeout=25) as r: code, body = r.status, r.read()
    except urllib.error.HTTPError as e: code, body = e.code, e.read()
    except Exception as e: code, body = "ERR", str(e).encode()
    try:
        d = json.loads(body); e = d.get("error") if isinstance(d, dict) else None
        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"
    except Exception: shape = "NOT_JSON"
    print(f"{m:4} {p[:40]:40} {code} {shape:12} {body[:120].decode(errors='replace')}")
    time.sleep(0.2)

Related

#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.

Payout

XE address: 6591eab453dbd93b27e2cd674712f94b42d9e7e4d52980b966fa6da4ccd832dc (same as #75; please confirm it is valid for the mainnet payout).

Thread

XE deskteam2026-11-10 00:15 UTCgithub

Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is updated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0057.