fix(MQTTTransport): reply with error instead of silently dropping malformed input (F-063)
Invalid JSON or a missing 'cmd' field on control/command previously logged
a WARNING on serial and returned with no reply at all — a client waiting
on control/ack had no way to tell "malformed request" apart from "message
never arrived" or "device offline," all three looking identical until its
own timeout fired.
Both onMessage() drop paths now publish an ERROR to control/ack before
returning: { "status": "ERROR", "type": "parse_error", "message": "..." }.
Unparseable JSON necessarily has no req_id (nothing to read it from); a
valid-but-cmd-less message echoes req_id if one was present. The heap-guard
drop above these two (hasHeapForPublish() check) is untouched — that one's
silence is deliberate, protecting against allocation under critical heap
pressure (see F-055), not something this fix should touch.
Bumped to v2.2.1. Verified: pio run -e vesper-std-v1 -e agnus-v1 both build clean.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -296,6 +296,15 @@ Structured telemetry for fleet-health graphing — not consumed by the phone app
|
||||
|
||||
`req_id` only appears in the reply if the request included one. Bus-wide unsolicited broadcasts (`CommandBus::broadcast()`) also publish here, with the same envelope shape and no `req_id` — but purpose-specific events (playback, alerts, reports, metrics) never use this path; they publish directly to their own topics instead.
|
||||
|
||||
### Malformed input
|
||||
|
||||
Invalid JSON or a missing `cmd` field gets an `ERROR` reply on `control/ack` (`type: "parse_error"`) instead of being silently dropped:
|
||||
|
||||
```json
|
||||
{ "status": "ERROR", "type": "parse_error", "message": "Invalid JSON: IncompleteInput" }
|
||||
{ "status": "ERROR", "type": "parse_error", "message": "Missing required field: cmd" }
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Server subscription pattern
|
||||
|
||||
Reference in New Issue
Block a user