{{ message }}
fix(core): make note_types search filter case-insensitive - #912
Merged
Conversation
Bug #14 (integration bug hunt): the search_notes note_types filter was case-sensitive on both backends. The MCP tool documents note_types as case-insensitive and lowercases the input ('Chapter' -> 'chapter'), but the stored frontmatter type preserves its casing ('Chapter'), so the SQL comparison never matched capitalized types. Fix folds case on both ends: - SQLite: LOWER(json_extract(metadata, '$.note_type')) IN (...) with lowercased param values. - Postgres: replace JSONB '@>' containment with LOWER(metadata->>'note_type') IN (...) with lowercased param values. Values stay parameterized, so SQL-injection protection is unchanged. Adds the regression test from the integration bug hunt under test-int/mcp/test_search_note_types_case_insensitive.py (real DB/ASGI/MCP client, no mocks): a capitalized 'type: Chapter' note is now matched by note_types=['Chapter'], plus a lowercase control. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
Contributor
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.

Summary
The
search_notesnote_typesfilter was case-sensitive on both the SQLite and Postgres backends, despite the MCP tool documenting it as case-insensitive. The tool lowercases the input ("Chapter"->"chapter"), but the stored frontmattertypevalue preserves its original casing ("Chapter"), so the SQL comparison never matched capitalized types. A note withtype: Chapterwas findable by plain text search but invisible tosearch_notes(note_types=["Chapter"]).This fix folds case on both ends of the comparison.
Bugs fixed
canvastool to create json canvas files in obsidian. #14 —note_typesfilter is case-sensitive despite documented case-insensitivity (capitalized frontmattertypevalues were unfindable).sqlite_search_repository.py): wrap the column inLOWER(json_extract(metadata, '$.note_type'))and lowercase the parameter values.postgres_search_repository.py): replace the JSONB@>containment check (exact-match) withLOWER(metadata->>'note_type') IN (...)and lowercase the parameter values.Testing
Test came from the integration bug hunt; added under
test-int/mcp/test_search_note_types_case_insensitive.py(real DB / ASGI / MCP client, no mocks).uv run pytest test-int/mcp/test_search_note_types_case_insensitive.py -q --no-cov-> 2 passed (SQLite)BASIC_MEMORY_TEST_POSTGRES=1 uv run pytest test-int/mcp/test_search_note_types_case_insensitive.py -q --no-cov-> 2 passed (Postgres)uv run pytest tests/repository/test_search_repository.py test-int/mcp/test_search_integration.py -q --no-cov-> 50 passed (SQLite)BASIC_MEMORY_TEST_POSTGRES=1 uv run pytest tests/repository/test_postgres_search_repository.py tests/repository/test_search_repository.py -q --no-cov-> 47 passed, 12 skipped (Postgres)uv run ruff check(scoped files) /uv run ruff format ./uv run ty check src tests test-int-> all passRisk
Low. The change only affects the
note_typesfilter clause. Lowercasing the stored value at comparison time broadens matching to be case-insensitive (the documented behavior); the SQL-injection regression tests fornote_typesstill pass on both backends. No tool signature changed.🤖 Generated with Claude Code