You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(analytics): Prefix Tool requests /analytics/hash-sizes®ion=… (missing '?'), gets HTML instead of JSON #179
The Prefix Tool's Network Overview builds a malformed URL for /analytics/hash-sizes whenever a region or area filter is active. The server answers with the SPA HTML (200 text/html), not JSON. .catch(() => null) cannot see this: the response is a 200, so it surfaces later as a failed JSON read and the tool falls back silently. The configured-hash-size counts (Kpa-clawbot#1270) are then missing, or wrong, exactly when a region is selected.
Found by the review of PR #175. It is pre-existing and not caused by that PR.
regionQueryString() returns '®ion=…' (public/region-filter.js ~64), so the path becomes /analytics/hash-sizes®ion=SJC with no ?. In the same call, fetchAllNodes('&sortBy=lastSeen' + rq, …) is correct, because that helper adds its own ?… prefix.
This was introduced with upstream #1270/#1271 (46ce9590, 2026-05-18), and the same line exists in upstream master.
Evidence (staging, 2026-10-03)
GET /api/analytics/hash-sizes®ion=SJC → 200 text/html; charset=utf-8
GET /api/analytics/hash-sizes?region=SJC → 200 application/json
Fix
Build the query correctly. For example, '/analytics/hash-sizes' + (rq ? '?' + rq.slice(1) : ''), or a small shared helper that turns &a=…&b=… into ?a=…&b=….
Check the other api('/analytics/…' + <something starting with '&'>) call sites for the same pattern. The Hash Stats tab uses sepBase (~327) and looks correct, but verify it.
Consider having api() treat a non-JSON 200 (Content-Type not JSON) as an error, so this class of bug fails loudly. If that turns out to be broad, make it a separate change.
Tests
Unit (vm harness): with a region and an area active, renderPrefixTool requests /api/analytics/hash-sizes?region=…&area=…; with neither active, it requests /api/analytics/hash-sizes.
Mutant: reverting to '/analytics/hash-sizes' + rq turns the test red.
E2E (optional): with a region selected, the Network Overview shows the configured-hash-size counts from the JSON.
Do not touch public/analytics.js while #175 (which also edits it) is open. Start from master after #175 is merged, or coordinate.
Activity
Merge pull request #191 from dborup/codex/issue-179-183-analytics
dborup commentedon Oct 3, 2026
Fixed by #191 (merged as
8e4b13d0). The Prefix Tool now requests/analytics/hash-sizes?region=…and gets JSON.Leftovers (low priority) are tracked in #193.