Skip to content

Strip the base endpoint path from relative API endpoints - #290

Merged
DavertMik merged 1 commit into
mainfrom
fix/api-endpoint-base-prefix
Nov 3, 2026
Merged

DavertMik merged 1 commit into
mainfrom
fix/api-endpoint-base-prefix

Conversation

@DavertMik

Copy link
Copy Markdown
Contributor

Problem

When the base endpoint has a path, an endpoint that repeats that path fails to resolve:

EXPLORBOT_URL=http://127.0.0.1:3000/api/v2/testomatio
explorbot api explore /api/v2/testomatio/comments --spec openapi_v2.yaml

Failed: Endpoint "/api/v2/testomatio/comments" not found in spec. Available: /projects, ..., /comments, /comments/{id}, ...

ApibotConfigParser.resolveEndpointPath stripped 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

resolveEndpointPath now 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: /v1users stays as it is under a /v1 base.

Verification

  • New unit test in tests/unit/apibot-config.test.ts.
  • Checked against the testomatio openapi_v2.yaml with base http://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/60 resolves the same as before
  • ApibotConfigParser environment fallback > enables Langfuse from LANGFUSE_* env vars fails on main too; this PR doesn't touch it.

🤖 Generated with Claude Code

`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>
@DavertMik
DavertMik merged commit 166f224 into main Nov 3, 2026
2 checks passed
@DavertMik
DavertMik deleted the fix/api-endpoint-base-prefix branch November 3, 2026 01:44
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.

1 participant