Skip to content

fix: validate revised body so get keeps stable JSON shape#3

Merged
edihasaj merged 3 commits into
mainfrom
fix/revise-body-shape
Jun 29, 2026
Merged

fix: validate revised body so get keeps stable JSON shape#3
edihasaj merged 3 commits into
mainfrom
fix/revise-body-shape

Conversation

@edihasaj

Copy link
Copy Markdown
Owner

Problem

Per #2: after remember, get returns body as a dict ({text: ...}). After revise, a subsequent get could return body as a list, changing the output JSON shape.

Cause

remember validates body.text, but revise stored req.patch.body unchecked. A malformed patch body (e.g. a list) silently persisted, so get returned an array.

Fix

Validate the successor draft in revise with validateDraft before persisting, mirroring remember. Invalid bodies are now rejected with invalid_record; valid revisions keep body as an object.

Tests

Added regression tests covering valid revise (object preserved) and malformed body (rejected, prior record untouched). Full suite: 54 passing; typecheck clean.

Fixes #2

edihasaj added 3 commits June 29, 2026 12:19
revise persisted req.patch.body unchecked, so a malformed body (e.g. a
list) corrupted the record and made body switch from object to array on a
subsequent get. Validate the successor draft before persisting, mirroring
remember.

Fixes #2
@edihasaj
edihasaj merged commit 86be9a7 into main Jun 29, 2026
1 check passed
@edihasaj
edihasaj deleted the fix/revise-body-shape branch June 29, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reference implementaiton: Revised memories change the output JSON format on a subsequent get

1 participant