Skip to content

fix(api/server): exact-equality routing for GET /v1/genomes/top (PKT-533) - #443

Open
bugsyhewitt wants to merge 1 commit into
mainfrom
fix/533-api-server-top-routing-prefix-overmatch
Open

fix(api/server): exact-equality routing for GET /v1/genomes/top (PKT-533)#443
bugsyhewitt wants to merge 1 commit into
mainfrom
fix/533-api-server-top-routing-prefix-overmatch

Conversation

@bugsyhewitt

Copy link
Copy Markdown
Owner

Summary

Fixes src/alienclaw/api/server.ts:203 routing defect where path.startsWith('/v1/genomes/top') silently dispatched unrelated paths (/v1/genomes/topology, /v1/genomes/topsecret, /v1/genomes/topfoo, etc.) to handleTopGenomes instead of returning 404 NOT_FOUND.

  • 1 LOC source change: replaces path.startsWith('/v1/genomes/top') || path === '/v1/genomes/top' with path === '/v1/genomes/top'
  • 91 LOC new tests: test/api/routing-prefix-mismatch.test.ts — 4 over-match cases (expect 404) + 2 control cases (expect 200), using the established vi.doMock storage pattern
  • Corrective re-issue of PKT-408 (branch fix/pkt-408-top-routing-prefix-shadow, never merged) and PKT-491 (branch fix/491-api-server-router-genomes-top-prefix-overmatch, never merged); this branch adds the test coverage from PKT-491

Test plan

  • TDD red confirmed: 4/6 new tests fail on buggy HEAD (getting 200 or 400 instead of 404)
  • TDD green confirmed: all 6 pass after 1-LOC fix
  • pnpm test exits 0 (vitest 2167 passed + 46 skipped, pytest 1206 passed + 125 skipped)
  • Runtime verify: real server.ts on scratch port returns 404 NOT_FOUND for all 4 over-match paths
  • Binding review: alienclaw-architect APPROVED, no blocking comments
  • Existing TopGenomes describe-block in test/api/ts-api-server.test.ts unaffected

🤖 Generated with Claude Code

…533)

Replace path.startsWith('/v1/genomes/top') || path === '/v1/genomes/top'
with path === '/v1/genomes/top' to prevent silent dispatch to handleTopGenomes
for unrelated paths (/topology, /topsecret, /topfoo, /topN, /toppings).

Adds 6-case regression test covering 4 over-match 404s + 2 control 200s,
mirroring the PKT-491 test diff that was never merged to main.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bugsyhewitt bugsyhewitt added the auto-merge-ok Binding review passed + ship-gate green — cleared for auto-merge label Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge-ok Binding review passed + ship-gate green — cleared for auto-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant