fix: normalize path prefix in wiki search so tenant filtering matches

get_wikijs_namespace() returns '/users/{user}' with a leading slash while
Wiki.js search results carry paths without one, so the prefix filter in
search_pages rejected every result - wiki search returned empty for every
tenant. Found by cross-repo integration verification; the librarian now
gets real search results. Compare slash-normalized on both sides.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-14 15:33:00 +02:00
co-authored by Claude Fable 5
parent 8b4eb3b77e
commit 0e57be75be
2 changed files with 26 additions and 2 deletions
+6 -2
View File
@@ -594,9 +594,13 @@ class WikiJSClient:
data = await self._execute_query(gql_query, {"query": query})
results = data.get("pages", {}).get("search", {}).get("results", [])
# Filter by path prefix if provided
# Filter by path prefix if provided. Wiki.js returns paths WITHOUT a
# leading slash while get_wikijs_namespace() produces one WITH it, so
# compare slash-normalized (the mismatch made this filter reject every
# result, returning an empty search for every tenant).
if path_prefix:
results = [r for r in results if r["path"].startswith(path_prefix)]
prefix = path_prefix.lstrip("/")
results = [r for r in results if r["path"].lstrip("/").startswith(prefix)]
return results