Fix BigInt serialization in GET /api/device (500 on real hardware) #14

Merged
kamilkrzywda merged 1 commits from fix/device-bigint into main 2026-09-24 23:14:32 +02:00
Owner

What

GET /api/device and MCP device_info returned 500 Do not know how to serialize a BigInt on the live device. protobuf-es decodes proto uint64 fields as native JS bigint; deviceInfo() passed raw decoded messages through unconverted (e.g. PowerConfig.powermonEnables). Unit tests missed it — fixtures never set a uint64 field.

Fix

One recursive jsonSafe converter (bigint → string, pass-through otherwise) applied at the single return-time choke point in deviceInfo() to metadata + every localConfig/moduleConfig section — covers REST and MCP alike, any current or future uint64 field. Redaction logic untouched.

Verification

  • New spec: power section frame with powermonEnables: 123n → value serializes as "123", JSON.stringify(deviceInfo()) succeeds
  • npm run build ✓, npm test — 34/34 passed (was 33)
  • v0.7.1, CHANGELOG entry added
## What `GET /api/device` and MCP `device_info` returned **500** `Do not know how to serialize a BigInt` on the live device. protobuf-es decodes proto `uint64` fields as native JS `bigint`; `deviceInfo()` passed raw decoded messages through unconverted (e.g. `PowerConfig.powermonEnables`). Unit tests missed it — fixtures never set a uint64 field. ## Fix One recursive `jsonSafe` converter (bigint → string, pass-through otherwise) applied at the single return-time choke point in `deviceInfo()` to metadata + every localConfig/moduleConfig section — covers REST and MCP alike, any current or future uint64 field. Redaction logic untouched. ## Verification - New spec: power section frame with `powermonEnables: 123n` → value serializes as `"123"`, `JSON.stringify(deviceInfo())` succeeds - `npm run build` ✓, `npm test` — 34/34 passed (was 33) - v0.7.1, CHANGELOG entry added
kamilkrzywda added 1 commit 2026-09-24 23:13:01 +02:00
kamilkrzywda merged commit ba5e60daf0 into main 2026-09-24 23:14:32 +02:00
kamilkrzywda deleted branch fix/device-bigint 2026-09-24 23:14:32 +02:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: OpenCode/MeshBot#14