Skip to content

Conversation

@chhoumann
Copy link
Owner

@chhoumann chhoumann commented Jan 17, 2026

Summary

  • Fix Android WebView crash in QuickAdd suggester filtering when query or options are undefined/non-string
  • Normalize suggester inputs at the API boundary and across suggester implementations
  • Add regression tests for undefined query handling

Issue

Closes #1078

Reproduction

  1. On Android (Obsidian 1.11.4), run a QuickAdd script that passes folder children to quickAddApi.suggester (see issue).
  2. Start typing to filter results.
  3. The suggester crashes with "Cannot read properties of undefined (reading 'toLowerCase')".

Root Cause

FuzzySuggestModal internally calls query.toLowerCase(). When the input event or options list includes undefined (e.g., folder children without a basename or programmatic updates that pass undefined), the query or option is not a string. This caused the Android WebView to throw at .toLowerCase(), breaking filtering and leaving the suggester unusable.

Fix

  • Introduce a single normalizeQuery helper so every suggester normalizes query values before fuzzy matching.
  • Normalize suggester options at the API boundary, so any entry point (including scripts and preflight input) receives safe string display items.
  • Ensure input suggesters normalize custom input values before comparisons.

Tests

  • bun run test

@vercel
Copy link

vercel bot commented Jan 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
quickadd Ready Ready Preview Jan 17, 2026 1:32pm

@coderabbitai
Copy link

coderabbitai bot commented Jan 17, 2026

📝 Walkthrough

Walkthrough

The PR introduces consistent input normalization across the suggester system by adding a normalizeQuery function that sanitizes query inputs and normalizes display items before suggestion matching, addressing undefined or malformed input handling in GenericSuggester, InputSuggester, SuggesterInputSuggest, and genericTextSuggester, with corresponding test coverage.

Changes

Cohort / File(s) Summary
Test coverage for undefined inputs
src/gui/GenericSuggester/genericSuggester.test.ts, src/gui/InputSuggester/inputSuggester.test.ts
Added test cases verifying that getSuggestions tolerates undefined query inputs without throwing errors.
Suggester implementations with query normalization
src/gui/GenericSuggester/genericSuggester.ts, src/gui/InputSuggester/inputSuggester.ts, src/gui/suggesters/SuggesterInputSuggest.ts, src/gui/suggesters/genericTextSuggester.ts
Applied normalizeQuery to incoming queries and normalized display items via normalizeDisplayItem before suggestion matching logic, ensuring consistent handling of input values across the suggester hierarchy.
Normalization utility additions
src/gui/suggesters/utils.ts
Added normalizeQuery(value: unknown): string as a wrapper around existing normalizeDisplayItem function, establishing a unified normalization entry point.
API-level normalization integration
src/quickAddApi.ts
Applied normalizeDisplayItem to suggester display items in the QuickAdd API flow.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 ✨

Queries hop through normalized gates so fair,
No undefined input shall cause despair,
Display items gently groomed with care,
Suggestions bloom consistent everywhere,
Android users now breathe easier air!

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: harden suggester filtering on Android' directly aligns with the PR's main objective of fixing the Android WebView crash in suggester filtering by normalizing inputs.
Linked Issues check ✅ Passed The PR successfully addresses issue #1078 by normalizing query and option values across all suggester implementations to prevent undefined-related crashes and restore filtering on Android.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the suggester crash: normalizing queries and display items at API boundaries, adding regression tests, and updating affected suggester implementations.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chhoumann chhoumann merged commit 4560f22 into master Jan 17, 2026
4 checks passed
@chhoumann chhoumann deleted the 1078 branch January 17, 2026 13:52
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.

[BUG] Use quickAddApi.suggester In Android has problem

2 participants