Validate medication JSONB arrays in rowToMedicationRecord - #2433
Conversation
rowToMedicationRecord now Zod-parses stats, sections, and quick and defaults each field to [] when the JSONB shape is unusable, so malformed catalogue rows cannot be treated as clinical arrays. Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Warning Review limit reachedNext included review available in 5 minutes. View limit detailsLimit details: You’ve used the included review currently available. Your 102 included PR review attempts over the past 7 days set your current allowance at 1 review per hour. Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Comment |
This pull request has been ignored for the connected project Preview Branches by Supabase. |
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_9b42e6d7-acc0-47e7-95f0-9d8960e6f2e9) |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_8bed57bf-fd05-4172-86aa-147bce7ebff8) |
Uh oh!
There was an error while loading. Please reload this page.
Summary
rowToMedicationRecordnow Zod-parses thestats,sections, andquickJSONB columns and defaults each field to[]when the payload is not a usable array of the expected clinical objects. Valid snapshot rows still parse in full, including nested patient metadata.database.types.tsJson = anyis unchanged, and medication accent defaults remain the Postgres column hex — they are not remapped to--clinical-accent.Verification
rowToMedicationRecordtest: malformed JSONB → empty arrays; valid rows parse (tests/medication-records.test.ts, 5 passed)Test Files 15 passed (15)/Tests 262 passed (262)npm run verify:pr-localverify:pr-localcompleted: check:runtime, check:installed-lock-parity, format:changed, lint, typecheck, test, check:repo-awareness-snapshot, build, check:rag:fixtures, check:medication-interactions, check:medication-lexicon-report. failed: (none). Full unit suite:Test Files 896 passed (896)/Tests 10839 passed | 1 skipped (10840). Build:Compiled successfully in 42s. Offline RAG fixtures:36 golden cases, 26 suites. Medication interactions:525 rowsup to date. Lexicon report:37 catalogue termsup to date.During development, use
npm run verify:cheapas the faster iteration gate before the final PR-local preflight.npm run verify:release— not requested; no release or handoff confidence claimFor retrieval, ranking, selection, chunking, source/citation rendering, or answer-contract changes,
verify:pr-localrunseval:rag:offlineautomatically. Run the offline command directly during iteration before spending a live eval.npm run check:production-readinessnot run: no privacy, environment, Supabase, source-governance, or deployment behaviour changed beyond conservative empty-array fallback on unusable catalogue JSONBnpm run check:deployment-readinessnot run: deployment startup, hosting, and rollout behaviour are unchangedRisk and rollout
ascast will now render empty stats/sections/quick instead of untyped objects. That is conservative degradation: clinicians see missing catalogue fields rather than a guessed shape. Well-formed snapshot and database rows keep their existing content.rowToMedicationRecordreturns to uncheckedascasts and the focused test is removed.Clinical Governance Preflight
Clinical KB Database(sjrfecxgysukkwxsowpy)This mapper change does not introduce or alter clinical decision-support behaviour. Unusable JSONB degrades to empty arrays rather than guessed clinical content. SaMD/TGA classification is unchanged.
Notes
PR 3e only. No
database.types.tsJson narrowing. No accent token remapping. No migrations.