fix(firestore): reject undeclared update keys, support typed dotted field paths - #83
Merged
Conversation
…d field paths Repository.update encoded through the model's update struct, which strips excess keys, so a Firestore field path like 'metaData.deleted' vanished and the SDK rejected the empty payload with an unrelated error (#63). - Encode all repository request payloads with onExcessProperty: 'error': an undeclared key fails with a SchemaError naming it. - Fail an empty update payload with FirestoreError invalid-argument. - Accept dotted field paths in update, typed via UpdateData<T>. Each path resolves to its leaf schema in Model.update (through Struct, Model.Struct, Class, Record, optional, OptionalDeletable) and encodes on its own, so nested sentinels and transforms work. Fixes #63 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Greptile SummaryThe PR makes repository request encoding strict and adds typed dotted-field updates with leaf-schema encoding and optional merge flattening.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; both previously reported issues are fixed by the current migration guidance and constrained Record-key validation.
|
| Filename | Overview |
|---|---|
| packages/effect-firebase/src/lib/firestore/model/update-path.ts | Adds bounded typed field-path resolution, constrained Record-key validation, and merge-payload flattening; the previously reported Record validation issue is fixed. |
| packages/effect-firebase/src/lib/firestore/model/repository.ts | Routes dotted update keys through leaf encoders, strictly validates ordinary fields, rejects empty payloads, and supports merge flattening. |
| packages/effect-firebase/src/lib/firestore/model/fetch.ts | Applies strict excess-property checking consistently to repository request encoders. |
| packages/effect-firebase/MIGRATION.md | Documents the strict-encoding breaking change, dotted paths, whole-map replacement, and merge-mode migration guidance. |
| packages/effect-firebase/src/lib/firestore/model/update-path.spec.ts | Covers nested schema traversal, constrained Record keys, recursive depth limits, merge flattening, and type-level path behavior. |
| packages/effect-firebase/src/lib/firestore/model/repository.spec.ts | Exercises strict request validation, dotted leaf encoding, sentinels, Record paths, merge semantics, and empty-update handling. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Repository.update] --> B{merge enabled?}
B -->|Yes| C[Flatten nested plain objects]
B -->|No| D[Keep supplied keys]
C --> E{Dotted field path?}
D --> E
E -->|Resolvable| F[Encode with leaf schema]
E -->|Not resolvable| G[Strict struct encoding]
F --> H[Build Firestore payload]
G --> H
H --> I{Payload empty?}
I -->|Yes| J[Fail invalid-argument]
I -->|No| K[Firestore update]
Reviews (4): Last reviewed commit: "feat(firestore): add { merge: true } to ..." | Re-trigger Greptile
…encoding in MIGRATION Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…r recursive schemas Walk SchemaAST (Objects, Union, Suspend, Declaration, encoding links) instead of the Schema wrapper API so Schema.suspend maps resolve. Cap paths at MAX_FIELD_PATH_DEPTH (5) at both type and runtime level: without a cap, UpdateData on a recursive type alias is a circular mapped type (TS2615). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Flattens a deep-partial payload into dotted field paths before the write, so nested objects merge into the stored map instead of replacing it. Leaves (arrays, class instances, sentinels, Option.none) are written whole; Option.some is merged into; empty objects contribute nothing. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
greptile-apps
Bot
dismissed
their stale review
September 10, 2026 06:50
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #63
Repository.updateencoded through the model's update struct, which strips excess keys. A Firestore field path like'metaData.deleted'was silently dropped and the SDK rejected the empty payload with an unrelated error.onExcessProperty: 'error': undeclared keys inadd/set/updatefail withSchemaErrornaming the key.FirestoreErrorcodeinvalid-argument.updateaccepts dotted field paths, typed viaUpdateData<T>. Each path resolves to its leaf schema inModel.update(throughStruct,Model.Struct,Class,Record,optional,OptionalDeletable) and encodes on its own, so nested sentinels and transforms work.Behavior change: junk keys previously dropped now error.
🤖 Generated with Claude Code