fix(api): exact-match /v1/genomes/top router predicate — drop startsWith over-match (PKT-491) - #418
Open
bugsyhewitt wants to merge 1 commit into
Open
Conversation
…ith over-match (PKT-491)
The `path.startsWith('/v1/genomes/top')` predicate silently dispatched
unrelated paths (e.g. /v1/genomes/topology, /v1/genomes/topsecret) to
handleTopGenomes instead of returning 404 NOT_FOUND. The `|| path ===
'/v1/genomes/top'` term was dead code — covered by startsWith already.
Replace with exact equality; adds regression test file covering 4
over-match cases + 2 control green cases.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
path.startsWith('/v1/genomes/top')inserver.ts:203silently dispatched unrelated paths (/v1/genomes/topology,/v1/genomes/topsecret, etc.) tohandleTopGenomes— returning 200 with empty entries or 400 MISSING_PARAMETER instead of 404 NOT_FOUND.if (path === '/v1/genomes/top'). The|| path === '/v1/genomes/top'term was dead code (already covered bystartsWith).test/api/routing-prefix-mismatch.test.ts— 4 over-match regression cases + 2 control green cases.Test plan
/v1/genomes/topology,/v1/genomes/topsecret,/v1/genomes/topologyxall return 404;/v1/healthreturns 200Files changed
src/alienclaw/api/server.ts— 1-LOC fix at line 203test/api/routing-prefix-mismatch.test.ts— new regression test file (~92 LOC)🤖 Generated with Claude Code