You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OpenAI-compatible Responses fallback requests could build invalid URLs like /v1/v1/responses when a custom base URL already included /v1 (or repeated /v1 suffixes). This caused fallback request failures for valid user configurations.
Implementation
Updated src/api/providers/openai-responses.ts to normalize custom base URLs before calling the fallback Responses endpoint.
The fallback now always resolves to a single /v1/responses path (no duplicated /v1).
Added regression tests in src/api/providers/__tests__/openai-responses.spec.ts for base URLs like /v1 and /v1/v1///.
How to Test
From src/, run:
pnpm test api/providers/__tests__/openai-responses.spec.ts
Verify the new tests pass and assert fetch is called with:
https://api.example.com/v1/responses
Confirm there is no duplicated /v1/v1/responses in fallback URL expectations.
Notes
Potential follow-up: apply the same normalization to src/api/providers/openai-native.ts and src/api/providers/apertis.ts.
Clean bug fix that extracts URL construction into a dedicated getResponsesApiUrl() method, properly normalizing base URLs that already contain /v1 to avoid path duplication in the fetch-based fallback. The regex approach is sound — trailing slashes are stripped first, then repeated /v1 segments are collapsed, and the method always appends /v1/responses. Edge cases (empty/whitespace URLs, multiple /v1 segments, trailing slashes) are well handled. Tests cover the key scenarios.
Files Reviewed (3 files)
.changeset/fair-dingos-bake.md - changeset
src/api/providers/openai-responses.ts - new getResponsesApiUrl() method with URL normalization
src/api/providers/__tests__/openai-responses.spec.ts - extracted mock helper, added 2 new test cases
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
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.
Context
Fixes #5979.
OpenAI-compatible Responses fallback requests could build invalid URLs like
/v1/v1/responseswhen a custom base URL already included/v1(or repeated/v1suffixes). This caused fallback request failures for valid user configurations.Implementation
src/api/providers/openai-responses.tsto normalize custom base URLs before calling the fallback Responses endpoint./v1/responsespath (no duplicated/v1).src/api/providers/__tests__/openai-responses.spec.tsfor base URLs like/v1and/v1/v1///.How to Test
src/, run:pnpm test api/providers/__tests__/openai-responses.spec.tsfetchis called with:https://api.example.com/v1/responses/v1/v1/responsesin fallback URL expectations.Notes
src/api/providers/openai-native.tsandsrc/api/providers/apertis.ts.