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) <noreply@anthropic.com>
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user