Bounty
XE-0063 · Bounty

openapi: state-chain read schemas are wrong (op/kv value typed string but is an object; /statechain/kv typed array but returns a map) (Medium)

Accepted claimed Medium xe#86 filed 2026-10-26 21:23 UTC by BoomGone

Report

  • Suggested tier: Medium ("inconsistent API responses"), Minor if seen as docs only
  • Area: openapi.json schemas StateOps, StateValue, StateValueList vs live /statechain/*
  • Found: 2026-10-26, node xe/92d83d1, openapi.json 1.0.0

Summary

The OpenAPI document is advertised as "the machine-readable contract" (llms.txt). Three state-chain schemas disagree with every live response:

  1. StateOps.items.value is {"type": "string"}, but op values are objects. /statechain/tip and /statechain/blocks[/{index}] return e.g. "value": {"epoch":3944,...} (epoch ops) or "value": {"keys":[...]} (keyset ops).
  2. StateValue.value is {"type": "string"}, but /statechain/kv/{key} returns an object for structured keys: GET /statechain/kv/sys.minter -> "value": {"keys":[...]}. It is a string only for scalar keys (sys.network_id -> "testnet-0005"). Same field, two shapes, typed as one.
  3. StateValueList is {"type": "array", ...}, but GET /statechain/kv returns a JSON object (a map keyed by state key), not an array: {"epoch.0": {...}, "epoch.1": {...}}.

Evidence (live 2026-10-26, https://test.network/api/v1)

GET /statechain/kv/sys.minter      -> {"key":"sys.minter","value":{"keys":["8bc63438...970d"]}}
GET /statechain/kv/sys.network_id  -> {"key":"sys.network_id","value":"testnet-0005"}
GET /statechain/tip                -> {... "ops":[{"action":"set","key":"epoch.3944","value":{"epoch":3944,...}}] ...}
GET /statechain/kv?limit=3         -> {"epoch.0":{...},"epoch.1":{...}}        (object, not array)

Spec (openapi.json 1.0.0):

StateOps      = array of { action:enum, key:string, value:{type:string} }
StateValue    = { key:string, value:{type:string}, additionalProperties:true }
StateValueList= { type:array, items:$ref StateValue }

Found with a conformance sweep of 22 read endpoints (poc/008-conformance.py): required-field and type check against each 200 schema. Only the state-chain endpoints mismatched; the other 18 conform.

Impact

  • Any client generated from openapi.json (the contract the docs point every integrator and agent to) deserialises value as a string and fails on every epoch op, keyset op, and sys.minter-style lookup, and expects an array from /statechain/kv but gets an object.
  • The state chain is the governance and emission surface and is in scope. Reading it via the documented contract does not work for structured values.
  • No fund risk.

Suggested fix

  • Type value as oneOf: [string, object] (or a documented union), or split scalar vs structured keys.
  • Change StateValueList to an object/map schema (additionalProperties: $ref StateValue) to match /statechain/kv, or make the endpoint return an array.

Payout

XE address: 6591eab453dbd93b27e2cd674712f94b42d9e7e4d52980b966fa6da4ccd832dc (same as #75).

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