Skip to content

Search crashes with "Cannot read property 'where' of undefined" when using field filters from the main Notes list (Android) #10101

Description

@chytrik

What happened?

Typing any search query containing a field filter (e.g. tag:meeting) into the search opened from the main Notes list on Android crashes with:

TypeError: Cannot read property 'where' of undefined

Plain full-text queries work fine. The same filter query also works fine when search is opened from inside a notebook, a tag, or Favorites — only the main Notes list is affected.

Likely root cause: The Search screen reads the note selector from route.params.items (apps/mobile/app/screens/search/index.tsx, case "note"db.lookup.notesWithHighlighting(query, route.params.items, ...)). All routes pass an items selector (e.g. Favorites passes db.notes.favorites, Notebook passes a relations selector) — except the Home screen (apps/mobile/app/screens/home/index.tsx), whose Navigation.push("Search", {...}) omits items entirely.

In packages/core/src/api/lookup.ts, notesWithHighlighting() then hits notes = notes.where(...) inside the if (filters > 0) branch with notes === undefined. That's why only filtered queries crash: plain queries never enter that branch. Note that the sibling method Lookup.notes() has a notes || this.db.notes.all fallback, but notesWithHighlighting() does not.

Suggested fix: either pass items: db.notes.all from the Home screen, or add the same fallback (notes ||= this.db.notes.all) in notesWithHighlighting().

Steps to reproduce the problem

  1. Open Notesnook on Android
  2. Go to the main Notes list (home screen)
  3. Tap the search icon
  4. Type any query with a field filter, e.g. tag:meeting (the tag doesn't need to exist)
  5. The app throws the TypeError

Version

App version: 3.4.6 Platform: android Model: google-Pixel 10 Pro Fold-17

Platform/OS

Android

Relevant log output

TypeError: Cannot read property 'where' of undefined
    at ?anon_0_ (address at index.android.bundle:1:4156986)
    at next (native)
    at fulfilled (address at index.android.bundle:1:4154858)
    at tryCallOne (address at InternalBytecode.js:1:1180)
    at anonymous (address at InternalBytecode.js:1:1874)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: ConfirmedBug is confirmed but work on a fix hasn't yet started.Type: BugSomething isn't workingplane

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions