Skip to content

[P3][lens] Clarify find() behavior when predicate field is undefined #36

Description

@cevheri

Summary

find({ field: undefined }) uses deepEqual where undefined matches documents missing the field — inverted vs typical JS { field: undefined } "must be undefined property" semantics.

Audit ID: Section 4 Low — Wave 3
Location: src/lens/document.ts:78-79, matches()

Fix options

  1. Treat explicit undefined in predicate as "field must exist and be undefined" (impossible for JsonValue) → match nothing for that key, or throw.
  2. Document that undefined means "field absent" explicitly in JSDoc.

Prefer (1) or exclude undefined keys from predicate iteration.

Acceptance criteria

  • Behavior documented or changed with tests in document.test.ts.
  • Changeset if behavior changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/lensesPre-announcement auditbugSomething isn't workingpriority/lowPre-announcement audit

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions