From 40b79962fb1d5523721bb1b4bff704ce46cbcd5a Mon Sep 17 00:00:00 2001 From: Andrew Yim Date: Tue, 28 Apr 2026 13:52:11 +0900 Subject: [PATCH] fix(notion-search): warn on --filter without --databases + DRY cache_kwargs Inline code review polish: - --filter is only meaningful in per-database mode (workspace search doesn't accept Notion filter objects). Previously a user passing --filter without --databases would have it silently parsed and ignored. Now emit a stderr warning and clear the filter. - cache_kwargs dict was built twice in run_search (once for cache_get, once for cache_put). Build once before the rerank call. 30/30 tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../31-notion-organizer/code/scripts/notion_search.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/custom-skills/31-notion-organizer/code/scripts/notion_search.py b/custom-skills/31-notion-organizer/code/scripts/notion_search.py index dc35602..c21a39a 100644 --- a/custom-skills/31-notion-organizer/code/scripts/notion_search.py +++ b/custom-skills/31-notion-organizer/code/scripts/notion_search.py @@ -380,8 +380,10 @@ def run_search( ] candidate_ids = [c["id"] for c in enriched] + # Pass cache_dir only if explicitly set; otherwise let _search_cache use its default. + cache_kwargs = {"cache_dir": cache_dir} if cache_dir else {} + if use_cache: - cache_kwargs = {"cache_dir": cache_dir} if cache_dir else {} cached = _search_cache.cache_get(query, candidate_ids, **cache_kwargs) if cached is not None: return cached @@ -389,7 +391,6 @@ def run_search( ranked = rerank(query, enriched, llm_caller=rerank_llm, limit=limit) if use_cache: - cache_kwargs = {"cache_dir": cache_dir} if cache_dir else {} _search_cache.cache_put(query, candidate_ids, ranked, **cache_kwargs) return ranked @@ -444,6 +445,10 @@ def main(): # Parse databases and filter databases = args.databases.split(",") if args.databases else None prop_filter = json.loads(args.filter) if args.filter else None + if prop_filter and not databases: + print("Warning: --filter is only applied in per-database mode; ignored without --databases", + file=sys.stderr) + prop_filter = None # Build notion client api_key = os.getenv("NOTION_API_KEY") or os.getenv("NOTION_TOKEN")