Skip to content

fix(providers): avoid duplicate /v1 in OpenAI Responses fallback URL#5990

Merged
kevinvandijk merged 3 commits intoKilo-Org:mainfrom
hdcodedev:fix/5979-openai-responses-v1-normalization
Feb 21, 2026
Merged

fix(providers): avoid duplicate /v1 in OpenAI Responses fallback URL#5990
kevinvandijk merged 3 commits intoKilo-Org:mainfrom
hdcodedev:fix/5979-openai-responses-v1-normalization

Conversation

@hdcodedev
Copy link
Contributor

Context

Fixes #5979.

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.

@changeset-bot
Copy link

changeset-bot bot commented Feb 19, 2026

🦋 Changeset detected

Latest commit: 7208c04

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
kilo-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Feb 20, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

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

Copy link
Collaborator

@kevinvandijk kevinvandijk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

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.

OpenAI Compatible didn't work well on Kilo code in IntelliJ IDEA

2 participants