<!-- XE-0063 · 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) · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0063>. The page is the record; this is the same page for reading.*

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](https://github.com/xeprotocol/xe/issues/86)
filed 2026-10-26 21:23 UTC
by BoomGone

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   Medium

Area
:   SDK / docs / web

Duplicate of
:   —

Tracked
:   internally

Updated
:   2026-11-10 11:38 UTC

Told
:   2026-11-10 00:15 UTC

### Patches

None linked.

### History

- [61395](https://bounty.xe.network/log/61395) 2026-11-10 00:15 UTC reply.mirrored
- [61352](https://bounty.xe.network/log/61352) 2026-11-10 00:15 UTC reply.sent
- [17833](https://bounty.xe.network/log/17833) 2026-11-07 16:08 UTC proposal.adopted
- [17832](https://bounty.xe.network/log/17832) 2026-11-07 16:08 UTC ticket.award
- [17831](https://bounty.xe.network/log/17831) 2026-11-07 16:08 UTC proposal.rejected
- [6895](https://bounty.xe.network/log/6895) 2026-11-05 13:45 UTC proposal.created
- [1820](https://bounty.xe.network/log/1820) 2026-11-02 19:16 UTC proposal.created
- [1474](https://bounty.xe.network/log/1474) 2026-11-02 10:11 UTC note.added
- [787](https://bounty.xe.network/log/787) 2026-10-29 14:22 UTC note.added
- [786](https://bounty.xe.network/log/786) 2026-10-29 14:22 UTC ticket.facts area
- [598](https://bounty.xe.network/log/598) 2026-10-29 14:04 UTC github.labels
- [456](https://bounty.xe.network/log/456) 2026-10-29 14:04 UTC ticket.status triaging → accepted

[Full history](https://bounty.xe.network/log?ref=XE-0063) · [JSON](https://bounty.xe.network/v1/tickets/XE-0063) · [markdown](https://bounty.xe.network/XE-0063.md)

### 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 desk**team2026-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.
