Relates to #215, #222
Problem
handlePostPacket (cmd/server/routes.go, POST /api/packets, behind requireAPIKey) writes transmissions, observers and observations through s.db.conn. The server opens that handle with mode=ro (Kpa-clawbot#1283).
- In production every call fails with
attempt to write a readonly database and returns 500, with the raw SQLite error text in the response.
- Route tests pass only because they run against a writable test DB.
- The handler also inserts without a by-hash lookup, so a repeated packet would violate
transmissions.hash UNIQUE even on a writable DB.
This was confirmed in the #222 review with a probe: OpenDB (mode=ro) plus a POST with a valid key returns 500, and the DB stays unchanged. In practice the endpoint has been dead since the read/write split.
Options
- (a) Hand the packet to the ingestor so the write happens where all writes live, e.g. via a queue or command table, or by republishing it over MQTT.
- (b) Remove the endpoint and its OpenAPI entry, if nothing uses it.
In both cases:
- remove
routes.go from knownServerWriteSQL;
- extend
TestServerHasNoPacketTableWrites to forbid INSERT everywhere in cmd/server;
- add a test that POSTs against an
OpenDB (mode=ro) store.
Acceptance
Relates to #215, #222
Problem
handlePostPacket(cmd/server/routes.go, POST/api/packets, behindrequireAPIKey) writestransmissions,observersandobservationsthroughs.db.conn. The server opens that handle withmode=ro(Kpa-clawbot#1283).attempt to write a readonly databaseand returns 500, with the raw SQLite error text in the response.transmissions.hash UNIQUEeven on a writable DB.This was confirmed in the #222 review with a probe:
OpenDB(mode=ro) plus a POST with a valid key returns 500, and the DB stays unchanged. In practice the endpoint has been dead since the read/write split.Options
In both cases:
routes.gofromknownServerWriteSQL;TestServerHasNoPacketTableWritesto forbidINSERTeverywhere incmd/server;OpenDB(mode=ro) store.Acceptance
cmd/serveroutside the documented exceptions (ping_score_history.go,backup.go).