-
Notifications
You must be signed in to change notification settings - Fork 8
as_json() still emits PascalCase keys in PUT requests (counterpart of #227) #238
Description
Description
ActiveDataSet.as_json() (and nested Timestamp.as_json(), SecurityPolicy.as_json()) still serializes PUT/POST request bodies using PascalCase keys (ActiveTimestamp, NetworkKey, ExtPanId, etc.), while the upstream ot-br-posix REST API expects camelCase (activeTimestamp, networkKey, extPanId, ...).
This is the serialization counterpart of #227, which fixed only the parsing direction (GET responses) by adding _normalize_keys() in commit 5e5197a.
Impact
When Home Assistant sends a PUT request (e.g. PUT /node/dataset/pending to change the Thread channel), otbr-agent rejects the payload because it uses cJSON_GetObjectItemCaseSensitive — PascalCase keys are silently ignored.
Captured with tcpdump on HA 2026.4.0:
PUT /node/dataset/pending HTTP/1.1
Content-Type: application/json
{"ActiveDataset":{"ActiveTimestamp":{"Authoritative":false,"Seconds":6,"Ticks":30314},"ChannelMask":134215680,"Channel":24,"ExtPanId":"...","NetworkKey":"...","PSKc":"...","SecurityPolicy":{"RotationTime":672,"ObtainNetworkKey":true,...}},"Delay":300000}
Expected by ot-br-posix (per OpenAPI spec):
{"activeDataset":{"activeTimestamp":{"authoritative":false,"seconds":6,"ticks":30314},"channelMask":134215680,"channel":24,"extPanId":"...","networkKey":"...","pskc":"...","securityPolicy":{"rotationTime":672,"obtainNetworkKey":true,...}},"delay":300000}
Suggested fix
Update as_json() in Timestamp, SecurityPolicy, ActiveDataSet and PendingDataSet to emit camelCase keys, matching the existing _CAMEL_TO_PASCAL mapping (reversed).
Versions
- Home Assistant 2026.4.0
- python-otbr-api 2.9.0
- ot-br-posix main (commit c18ae69e)