Skip to content

fix(backend): JSON-sanitize Typesense structured timestamps - #15328

Merged
Git-on-my-level merged 1 commit into
mainfrom
fix/typesense-structured-json
Sep 21, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
fix/typesense-structured-json

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Root cause

Prod first-party Typesense dual-write (typesense_index.py) started running after #15107, then fail-opened on every upsert whose structured blob still carried Firestore DatetimeWithNanoseconds (Object of type DatetimeWithNanoseconds is not JSON serializable). 37 of those in 2h on serving 16fc207. Search stayed on the Firebase extension.

Failure class (fixes)

Failure-Class: none

Fix

Sanitize structured (and nested lists/dicts) to JSON-safe values before upsert: datetimes → unix seconds, GeoPoints → [lat, lng]. Top-level timestamps were already epoch-coerced; nested structured.events.*.created_at was not.

Test

pytest tests/unit/test_conversation_typesense_index.py::TestDocumentShape — 8 passed, including test_structured_firestore_datetime_is_json_serializable (json.dumps of a DatetimeWithNanoseconds subclass).

Rollout

Does not uninstall the Typesense extension. After merge+prod deploy, re-run the C018 coverage gate; remove the Eventarc trigger only if that PASSes.

Review in cubic

Nested Firestore DatetimeWithNanoseconds in structured.* made Typesense
upserts fail-open after the dual-write client() fix. Convert datetimes
to epoch seconds before upsert.

Failure-Class: none
@Git-on-my-level
Git-on-my-level merged commit f875f6c into main Sep 21, 2026
64 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/typesense-structured-json branch September 21, 2026 04:13
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.

1 participant