Skip to content

[WRONG BRANCH] fix(adapters): preserve Responses URL authority by normalizing only the pathname - #280

Draft
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-url-helper-to-prevent-credential-misrouting
Draft

[WRONG BRANCH] fix(adapters): preserve Responses URL authority by normalizing only the pathname#280
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-url-helper-to-prevent-credential-misrouting

Conversation

@luvs01

@luvs01 luvs01 commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Motivation

  • A URL-normalization helper applied suffix regexes to the entire baseUrl string and could rewrite the authority for host-only inputs (e.g. https://responses), which risks sending provider credentials to an unintended origin.
  • The change aims to prevent credential-misrouting by ensuring only the URL pathname is normalized before appending the legacy /v1/responses path.

Description

  • Replace string-suffix trimming with a proper URL parse in src/adapters/openai-responses-url.ts and operate on url.pathname so authority/host is never altered.
  • Compute trimmedPath, strip trailing /, /responses, or /v1 only from the pathname, then set url.pathname = ${withoutV1}/v1/responses`` and return url.toString().
  • Add a regression case to tests/openai-responses-passthrough.test.ts asserting that a host-only base URL https://responses becomes https://responses/v1/responses (and does not change the authority).

Testing

  • Ran the focused Responses tests with the repository Bun binary via node_modules/@oven/bun-linux-x64-baseline/bin/bun test --isolate tests/openai-responses-passthrough.test.ts and the file passed (68 tests, including the new openaiResponsesUrl case).
  • Ran bun run typecheck and bun run privacy:scan, both of which succeeded.
  • Attempted a full bun run test; the full suite exercised unrelated tests and encountered timeouts/failures outside the modified subsystem, so only the focused tests were relied upon for verification.

Codex Task

Summary by CodeRabbit

  • Bug Fixes
    • Improved Responses API URL handling for base URLs with or without paths.
    • Preserved existing query parameters and fragments when constructing endpoint URLs.
    • Restored the expected /v1/responses suffix for bare base URLs.
    • Invalid URL inputs now fail clearly during parsing.

@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 14, 2026
@github-actions github-actions Bot changed the title fix(adapters): preserve Responses URL authority by normalizing only the pathname [WRONG BRANCH] fix(adapters): preserve Responses URL authority by normalizing only the pathname Aug 14, 2026
@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions
github-actions Bot marked this pull request as draft August 14, 2026 08:33
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: cc35f4cd-8ade-4687-918a-9fd0bd4024b0

📥 Commits

Reviewing files that changed from the base of the PR and between f05ba75 and 100759d.

📒 Files selected for processing (2)
  • src/adapters/openai-responses-url.ts
  • tests/openai-responses-passthrough.test.ts

📝 Walkthrough

Walkthrough

The Responses adapter now parses and normalizes the base URL before appending /v1/responses. The test suite covers a pathless key-auth base URL and verifies the normalized result.

Changes

Responses URL normalization

Layer / File(s) Summary
URL construction and regression coverage
src/adapters/openai-responses-url.ts, tests/openai-responses-passthrough.test.ts
openaiResponsesUrl uses URL parsing and pathname normalization. The test verifies that https://responses becomes https://responses/v1/responses for key-auth requests.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 10075

This localized change preserves the URL authority while normalizing the Responses pathname, with a regression test covering the affected host-only case; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: ingwannu

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: preserving Responses URL authority while normalizing only the pathname.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-url-helper-to-prevent-credential-misrouting

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant