Skip to content

Horizon API + web: fix Track 4 integration bugs and bearer auth - #140

Merged
IanCou merged 2 commits into
masterfrom
fix/horizon-read-api-bugs
Nov 14, 2026
Merged

IanCou merged 2 commits into
masterfrom
fix/horizon-read-api-bugs

Conversation

@SuperNova-W

Copy link
Copy Markdown
Collaborator

Fixes bugs found running the Horizon API and web app (from #132/#133) against Track 4's real schema. Spec drift is intentionally left alone.

API

  • Read runs with Track 4's published status (it only accepted complete, which Track 4 never writes, so every rankings request would 404).
  • Accept group_too_small member rows (previously a 500).
  • Accept bucket_scores as {key: score}; add comparisonGroupLabel.
  • Member history stops at the selected run.
  • Unranked rows sorted by name.
  • prepare_threshold=None for the Supabase transaction pooler.
  • Unknown routes use the error envelope.

Web

  • Send the access token as Authorization: Bearer (the client sent cookies, which the API rejects with 401). Still locked until T7.1 sign-in exists.

Tests

  • horizonserver: 57 passed (6 new regression tests, each fails on the old code), ruff clean.
  • horizonui: typecheck, lint, 124 tests, prettier, build, verify-production.
  • End to end in Chromium against the running API: old cookie request → 401, fixed bearer request → authenticated.

@tvworks22 could you review? It's your code 🙏

- Select runs with Track 4's status 'published' (running/scored/failed are
  never readable). The API only accepted 'complete', which Track 4 never
  writes, so every rankings request would have returned 404.
- Accept Track 4 member statuses (ranked, insufficient_data,
  group_too_small). group_too_small rows previously failed response
  validation (500). No non-ranked row may carry a score or rank.
- Accept bucket_scores as Track 4 publishes it ({key: score}); bucket
  weight is optional. Add comparisonGroupLabel.
- Member history stops at the selected run, so an older week no longer
  shows later weeks.
- Order unranked rows by name instead of user id.
- Disable prepared statements on the pool (Supabase transaction pooler).
- Unknown routes and wrong methods use the {"error": {...}} envelope.
- Regenerate openapi.json. Six regression tests, each failing before.
The web client sent same-origin cookies, but the Horizon API only accepts
Authorization: Bearer, so every live read would have been rejected with
401. The auth adapter now exposes getAccessToken(); the read client sends
the token as a bearer header with credentials omitted, refuses to fetch
without a token, and rejects malformed tokens. The adapter still returns
no token until Authentik sign-in (T7.1) exists, so the release gates stay
closed.

Also align the provisional T6.2 types with Track 4 statuses
(group_too_small) and optional bucket weights.
@IanCou
IanCou merged commit c7f3ed5 into master Nov 14, 2026
1 check passed
@IanCou
IanCou deleted the fix/horizon-read-api-bugs branch November 14, 2026 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants