omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty Proposal] fix(backend): one malformed stored advice row 500s the whole advice feed ($25-50 proposed)

Open nguyentruong190 opened this issue 2 months ago • 0 comments

Summary

database.advice.get_advice returned raw Firestore dicts (only the doc id injected) into GET /v1/advice response_model=list[Advice]. Advice requires content/category/created_at/updated_at, so one legacy or corrupted stored document (a partial write or an older producer shape) made FastAPI raise ResponseValidationError — HTTP 500 — for the users entire advice feed until the document was fixed manually. Same failure class as the desktop journal reconcile page (#20271) and the earlier desktop-messages guard.

Fix

Parse rows through the shared read boundary (database.read_boundary.parse_snapshots) — the canonical prevention artifact for FC-malformed-doc-read — in backend/database/advice.py: malformed rows are dropped with non-PII telemetry (path + validation field names/types only), valid rows are returned as Advice models. update_advices re-read uses parse_snapshot_or_none so a poisoned row surfaces as 404 upstream instead of a 500 from the PATCH response serializer.

Tests

backend/tests/unit/test_advice_read_boundary.py — 13 hermetic unit tests (no network, no services): missing content/category/timestamps, out-of-range and wrong-typed confidence, and non-mapping payloads are dropped; valid pages survive intact; the document id populates Advice.id; pagination arguments reach the query; PATCH on a poisoned row returns None (404 upstream); a structural check keeps advice reads on the shared boundary. The existing advice router contract suite passes unchanged (31 passed combined).

Proposed Bounty

  • $25–50 (read-boundary poison-page hardening; FC-malformed-doc-read instance).

Payout (PayPal): [email protected]

Disclosure: investigation, patch, and tests were prepared with an AI assistant. This proposal does not represent independent human technical review.

nguyentruong190 avatar Oct 02 '26 05:10 nguyentruong190