Skip to content

as_json() still emits PascalCase keys in PUT requests (counterpart of #227) #238

@jnilo1

Description

@jnilo1

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions