fix: StripRequestPath returns "/" when base path fully consumes request path#265
Merged
daveshanley merged 1 commit intopb33f:mainfrom Apr 26, 2026
Merged
Conversation
…st path When a server URL contains a path that is identical to the incoming request path (e.g. servers[0].url = "https://things.com/v1beta/openai/chat/completions" and request path "/v1beta/openai/chat/completions"), stripBaseFromPath leaves an empty string. The guard prevented the leading "/" from being restored, so downstream segment-based comparison in FindPath's slow path could not match the spec's "/" route. Remove the len(stripped) > 0 guard so an emptied stripped path always becomes "/", which correctly maps to a spec declaring paths: { "/": ... }. Adds a table-driven TestStripRequestPath covering the bug case plus regression cases, and TestNewValidator_FindPath_BasePathFullyConsumesRequestPath exercising the slow path end-to-end.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #265 +/- ##
==========================================
- Coverage 97.97% 97.89% -0.09%
==========================================
Files 64 64
Lines 6627 8119 +1492
==========================================
+ Hits 6493 7948 +1455
- Misses 133 170 +37
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
I've run the coverage check locally and nothing wrong is reported. This looks like a bug on the CI. |
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
paths.StripRequestPathreturns""(instead of"/") when the base path derived fromservers[0].urlexactly consumes the request path. The subsequent segment-based comparison insideFindPath's slow path then splits""into an empty slice, while the spec's/route splits into[""](one empty segment), socomparePathsshort-circuits on the length mismatch and the request is reported as "Path not found".Example that hits the bug:
A
POST https://things.com/v1beta/weathershould match the/operation but today returns a validation error.Fix
Drop the
len(stripped) > 0 &&guard so an emptied stripped path is re-prefixed to"/", which matches a spec declaringpaths: { "/": ... }.