Skip to content

Commit d6ff191

Browse files
Fix stats endpoint missing tenant authentication (#134)
The /v1/default/banks/{bank_id}/stats endpoint was missing the request_context parameter and tenant authentication call, causing it to query the public schema instead of the tenant's schema. This resulted in stats always returning zeros for multi-tenant deployments since the data lives in tenant-specific schemas. Added request_context dependency and _authenticate_tenant() call to properly set the tenant schema before querying stats.
1 parent 3bb6a38 commit d6ff191

File tree

1 file changed

+6
-1
lines changed
  • hindsight-api/hindsight_api/api

1 file changed

+6
-1
lines changed

hindsight-api/hindsight_api/api/http.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,9 +1360,14 @@ async def api_list_banks(request_context: RequestContext = Depends(get_request_c
13601360
operation_id="get_agent_stats",
13611361
tags=["Banks"],
13621362
)
1363-
async def api_stats(bank_id: str):
1363+
async def api_stats(
1364+
bank_id: str,
1365+
request_context: RequestContext = Depends(get_request_context),
1366+
):
13641367
"""Get statistics about memory nodes and links for a memory bank."""
13651368
try:
1369+
# Authenticate and set tenant schema
1370+
await app.state.memory._authenticate_tenant(request_context)
13661371
pool = await app.state.memory._get_pool()
13671372
async with acquire_with_retry(pool) as conn:
13681373
# Get node counts by fact_type

0 commit comments

Comments
 (0)