{"id":"XE-0063","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"86","source_url":"https://github.com/xeprotocol/xe/issues/86","reporter_id":25,"title":"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)","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:20.007048+00:00","updated_at":"2026-11-10T11:38:21.947945+00:00","source_created_at":"2026-10-26T21:23:35+00:00","told_at":"2026-11-10T00:15:44+00:00","status_changed_at":"2026-10-29T14:04:13.259824+00:00","url":"https://bounty.xe.network/XE-0063","body":"- Suggested tier: Medium (\"inconsistent API responses\"), Minor if seen as docs only\n- Area: openapi.json schemas StateOps, StateValue, StateValueList vs live /statechain/*\n- Found: 2026-10-26, node `xe/92d83d1`, openapi.json 1.0.0\n\n## Summary\n\nThe OpenAPI document is advertised as \"the machine-readable contract\" (llms.txt). Three state-chain schemas disagree with every live response:\n\n1. `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).\n2. `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.\n3. `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\": {...}}`.\n\n## Evidence (live 2026-10-26, https://test.network/api/v1)\n\n```\nGET /statechain/kv/sys.minter      -> {\"key\":\"sys.minter\",\"value\":{\"keys\":[\"8bc63438...970d\"]}}\nGET /statechain/kv/sys.network_id  -> {\"key\":\"sys.network_id\",\"value\":\"testnet-0005\"}\nGET /statechain/tip                -> {... \"ops\":[{\"action\":\"set\",\"key\":\"epoch.3944\",\"value\":{\"epoch\":3944,...}}] ...}\nGET /statechain/kv?limit=3         -> {\"epoch.0\":{...},\"epoch.1\":{...}}        (object, not array)\n```\n\nSpec (openapi.json 1.0.0):\n\n```\nStateOps      = array of { action:enum, key:string, value:{type:string} }\nStateValue    = { key:string, value:{type:string}, additionalProperties:true }\nStateValueList= { type:array, items:$ref StateValue }\n```\n\nFound 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.\n\n## Impact\n\n- 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.\n- 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.\n- No fund risk.\n\n## Suggested fix\n\n- Type `value` as `oneOf: [string, object]` (or a documented union), or split scalar vs structured keys.\n- Change `StateValueList` to an object/map schema (`additionalProperties: $ref StateValue`) to match `/statechain/kv`, or make the endpoint return an array.\n\n## Payout\n\nXE address: `6591eab453dbd93b27e2cd674712f94b42d9e7e4d52980b966fa6da4ccd832dc` (same as #75).\n","patch_refs":[],"thread":[{"id":1572,"source":"github","source_ref":"6755093121","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-0063.","created_at":"2026-11-10T00:15:44+00:00"}]}