Skip to content

Commit 1028865

Browse files
committed
internal: clarify intent of Scalar.denormalize falsy guard
Made-with: Cursor
1 parent ef3b6b8 commit 1028865

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

packages/endpoint/src/schemas/Scalar.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ export default class Scalar implements Mergeable {
156156
}
157157

158158
denormalize(input: any, delegate: IDenormalizeDelegate): any {
159+
// Deliberately broad falsy guard — not just `null`/`undefined`. In normal
160+
// flow `input` is a wrapper tuple (array), a cpk string, a cell object, or
161+
// a symbol (INVALID propagation). A primitive non-string like `0`/`false`
162+
// can only appear from a malformed store or a direct unit-test call; if
163+
// one reached the Values branch below it would infinite-recurse via
164+
// `delegate.unvisit(this, 0) → unvisit → schema.denormalize(0, …)` since
165+
// `isEntity(this)` is false and the string-input fast path doesn't match.
166+
// Returning it verbatim is the safe terminal case. Memoization stays
167+
// coherent because `input` comes from the stored entity row, so any shape
168+
// change implies a new entity reference and a full re-traversal — the
169+
// cached `argsKey`-bearing chain is never replayed against a frame that
170+
// skipped the guard.
159171
if (!input || typeof input === 'symbol') return input;
160172

161173
// Entity-field wrapper: `[entityPk, fieldName, entityKey]` (see normalize).

0 commit comments

Comments
 (0)