fix(agent): send search param instead of ignored q to /api/dashboards

The backend route binds the search query to `search`; a bare `q` param is
not bound, so search_dashboards and prefetch_dashboards silently returned
the unfiltered catalog (e.g. query 'Sales' listed all 11 dashboards).
Switch both to `search` and update the URL-contract test.
This commit is contained in:
2026-08-19 19:31:32 +03:00
parent e291ba757f
commit 9b0350b3b0
3 changed files with 9 additions and 4 deletions

View File

@@ -210,7 +210,8 @@ async def prefetch_dashboards(env_id: str) -> str:
# profile filter, so prefetch reflects the whole environment instead of the
# user's filtered view (which would report "No dashboards found." for every
# dashboard without matching owner metadata). page_size=100 avoids truncation.
params={"q": "", "env_id": env_id or "", "page_context": "other", "page_size": 100},
# The query param must be `search` (backend binds `search`; `q` is ignored).
params={"search": "", "env_id": env_id or "", "page_context": "other", "page_size": 100},
headers=_dual_auth_headers(),
)
if resp.status_code != 200:

View File

@@ -380,9 +380,11 @@ async def search_dashboards(query: str, env_id: str | None = None) -> str:
extra={"src": "AgentChat.Tools.SearchDashboards"})
# Full-catalog search: page_context=other disables the profile-default filter,
# page_size=100 avoids truncation for environments with more dashboards than
# the default page size (10).
# the default page size (10). The query param must be `search` (the backend
# route binds `search`; a bare `q` is ignored and returns the unfiltered
# catalog, silently defeating the search).
params = {
"q": query,
"search": query,
"env_id": env_id or "",
"page_context": "other",
"page_size": 100,

View File

@@ -233,7 +233,9 @@ async def test_search_dashboards_correct_url():
params = kwargs.get("params", {})
assert params.get("page_context") == "other"
assert params.get("page_size") == 100
assert params.get("q") == "dashboard-name"
# The backend binds `search` (a bare `q` param is ignored and returns the
# unfiltered catalog, silently defeating the search).
assert params.get("search") == "dashboard-name"
assert params.get("env_id") == "prod"