fix(audit): remove coarse per-request middleware that wrote unusable rows #198
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/pms-275-remove-coarse-audit-middleware"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The per-request audit middleware (PMS-119) fired post-response with only the HTTP method and URL available, so it always passed
Noneforentity_idand the old/new value payload, producing rows with record "-" and null before/after values. Because the API router is nested under/api/v1, the path the middleware saw was already prefix-stripped, sostrip_prefix("/api/v1/")always returnedNoneand every row was tagged entity_type "unknown". These junk rows sat interleaved with the rich rows and, for instrumented modules, duplicated them.The in-transaction
audit_writepath (PMS-117) is the canonical audit writer: it runs inside the mutation's transaction and records the entity type, record id, and JSONB before/after snapshots. Remove the coarse middleware (its layer wiring, the module, and the now-unusedAuditService::append) soaudit_writeis the sole writer and every audit entry carries the entity, record, and payload the trail needs.#PMS-275
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
The per-request audit middleware (PMS-119) fired post-response with only the HTTP method and URL available, so it always passed `None` for `entity_id` and the old/new value payload, producing rows with record "-" and null before/after values. Because the API router is nested under `/api/v1`, the path the middleware saw was already prefix-stripped, so `strip_prefix("/api/v1/")` always returned `None` and every row was tagged entity_type "unknown". These junk rows sat interleaved with the rich rows and, for instrumented modules, duplicated them. The in-transaction `audit_write` path (PMS-117) is the canonical audit writer: it runs inside the mutation's transaction and records the entity type, record id, and JSONB before/after snapshots. Remove the coarse middleware (its layer wiring, the module, and the now-unused `AuditService::append`) so `audit_write` is the sole writer and every audit entry carries the entity, record, and payload the trail needs. #PMS-275 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>