Repository navigation
Strip the base endpoint path from relative API endpoints - #290
Merged
Merged
Conversation
`api explore /api/v2/acme/comments` with a base endpoint of `http://host/api/v2/acme` failed with "not found in spec". The base path was stripped only from absolute URLs, so a relative endpoint that repeated the base prefix kept it and matched no spec path. Co-Authored-By: Claude Opus 5.5 <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.
Problem
When the base endpoint has a path, an endpoint that repeats that path fails to resolve:
ApibotConfigParser.resolveEndpointPathstripped the base path only from absolute URLs, or when a site was set. A relative endpoint returned early, still carrying the prefix, so it matched none of the spec paths (which are normalized relative to the base). Planning and requests were affected too: the client would have called<base>/api/v2/testomatio/comments.This happens often when another agent writes the endpoint list from routes or controllers, because those show the full path.
Fix
resolveEndpointPathnow strips the base path from relative endpoints as well. A path is stripped only when it starts with the whole base path at a segment boundary:/v1usersstays as it is under a/v1base.Verification
tests/unit/apibot-config.test.ts.openapi_v2.yamlwith basehttp://127.0.0.1:3000/api/v2/testomatio:/api/v2/testomatio/comments→/comments→/api/v2/{project_id}/comments,/comments/{id}/api/v2/testomatio/comments/60→/comments/60→/api/v2/{project_id}/comments/{id}/comments/60resolves the same as beforeApibotConfigParser environment fallback > enables Langfuse from LANGFUSE_* env varsfails onmaintoo; this PR doesn't touch it.🤖 Generated with Claude Code