Skip to content

fix(validation): accept ISO sourceAddedAt in documents-with-memories responses - #1867

Closed
abhisheksharma001 wants to merge 1 commit into
supermemoryai:mainfrom
abhisheksharma001:fix/validation-source-added-at-iso
Closed

abhisheksharma001 wants to merge 1 commit into
supermemoryai:mainfrom
abhisheksharma001:fix/validation-source-added-at-iso

Conversation

@abhisheksharma001

@abhisheksharma001 abhisheksharma001 commented Nov 2, 2026 •

Copy link
Copy Markdown

Bug

DocumentsWithMemoriesResponseSchema declares memoryEntries[].sourceAddedAt as z.date(), but the API returns it as an ISO string, like every other timestamp in the response. $fetch("@post/documents/documents", ...) and the /by-ids variant therefore fail validation on any document that has memory entries:

documents.0.memoryEntries.0.sourceAddedAt: Expected date, received string

createdAt and updatedAt on the same entry already use z.coerce.date(), so this field was the odd one out.

Fix

sourceAddedAt: z.coerce.date().nullable(). Consumers keep getting a Date, as the inferred type already promised, and null still passes through.

Verification

  • New tests parse a response shaped like the live one: an ISO sourceAddedAt becomes a Date for the same instant, and null stays null.
  • The ISO test fails on main with Expected date, received string and passes here.
  • bun test over packages/validation (zod 3.25.76 and zod-openapi 4.2.4, as pinned in bun.lock): 31 pass. tsc --noEmit over packages/validation and packages/lib is clean, and so is Biome on the changed files.
  • The repo's CI also passes on this commit in a run on my fork, since it needs maintainer approval to run here. That is CI - Type Check, Format & Lint, the only workflow this change triggers.

Fixes #1847. Overlaps with #1848, which was opened for the same issue; happy to close either one.

🤖 Generated with Claude Code

…responses

MemoryEntryAPISchema required sourceAddedAt to be a Date, but the API sends
it as an ISO string like every other timestamp, so $fetch rejected every
/v3/documents/documents and /by-ids response that contained a memory entry.
Coerce it the same way the neighbouring createdAt and updatedAt already are.

Fixes supermemoryai#1847

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@abhisheksharma001

Copy link
Copy Markdown
Author

#1932 removed packages/validation and packages/lib from main, so the code this PR fixes no longer exists. Closing.

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.

[Bug] DocumentsWithMemoriesResponseSchema rejects ISO sourceAddedAt from live /v3 responses

1 participant