Skip to content

fix(responses): normalize forward base URLs with a linear scan - #7348

Closed
luvs01 wants to merge 1 commit into
lidge-jun:devfrom
luvs01:fix/responses-forward-baseurl-scan-20261019
Closed

luvs01 wants to merge 1 commit into
lidge-jun:devfrom
luvs01:fix/responses-forward-baseurl-scan-20261019

Conversation

@luvs01

@luvs01 luvs01 commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Replace provider.baseUrl.replace(/\/+$/, "") on the noncanonical forward path in buildResponsesTransport (src/adapters/openai-responses/transport.ts) with stripTrailingSlashes, a linear scan that drops the trailing / run by walking each character once. /\/+$/ retries candidate end positions when a long slash run is not at the end of the string (the CodeQL js/polynomial-redos shape); the scan produces the same normalized URL on every input without that behavior.
  • Add tests/responses/responses-forward-transport-baseurl.test.ts pinning the normalization in a sibling file, since openai-responses-passthrough.test.ts is at its file-size cap: multiple, single, and absent trailing slashes; preserved interior slash runs; and a long mid-path slash run.
  • Canonical forward providers keep CODEX_FORWARD_BASE_URL; only the configured baseUrl path changes. Provider config validation already requires an absolute http(s) baseUrl, so empty and slash-only values stay outside this call's contract.
  • Record the new normalization contract in the owning structure doc (structure/providers-and-adapters.md).

Verification

  • Hosted Cross-platform CI passed for fac63237555cbe2730f11cdcf489231a4b2a51ff (run 39201522639, attempt 1): 14 jobs passed, including all four Linux test shards and aggregate ci; 9 conditional jobs were skipped.
  • bun test tests/responses/responses-forward-transport-baseurl.test.ts tests/responses/openai-responses-passthrough.test.ts tests/test-layout.test.ts tests/test-layout-tooling.test.ts — 217 pass / 0 fail on Bun 1.4.3.
  • bun node_modules/typescript/bin/tsc --noEmit — clean.
  • bun scripts/structure-ssot.ts — "structure/ SSOT checks passed".
  • bun scripts/privacy-scan.ts — "Privacy scan passed" (over a sparse checkout limited to src/, tests/, scripts/, structure/, .github/, and the one devlog/_fin directory the layout oracle reads).
  • Equivalence spot-check (scratch script, not committed): stripTrailingSlashes matched /\/+$/ output on 24 deterministic inputs including trailing/single/interior slash runs, \n, \r\n, \u2028, \u2029, tab, NUL, and surrogate pairs.
  • File-size ratchet verified by inspection of the changed files: none carries a baseline cap and all are under the 2000-line threshold; the full-repo scan needs a complete checkout and is left to CI.
  • Local validation is intentionally focused on this transport-only change; the full suite is left to hosted PR CI rather than repeated locally.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed (the owning structure doc records the new normalization contract; no user-visible behavior change).
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Summary by CodeRabbit

  • Bug Fixes
    • Forward-mode Responses requests now consistently remove trailing slashes from configured base URLs while preserving slash sequences within the URL. URLs without trailing slashes remain unchanged.
  • Tests
    • Added coverage for trailing-slash handling, preserved interior slashes, and long slash sequences.
  • Documentation
    • Clarified how base URLs are handled for forward-mode requests.

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 3952f7eb-bf08-4c0a-9ee8-1e5c61dca9e5
📥 Commits

Reviewing files that changed from the base of the PR and between d11f067 and fac6323.

📒 Files selected for processing: 5
  • scripts/test-layout/layout.json
  • src/adapters/openai-responses/transport.ts
  • structure/providers-and-adapters.md
  • tests/fixtures/test-layout-expected.json
  • tests/responses/responses-forward-transport-baseurl.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The Responses forward transport now removes trailing slashes from noncanonical provider base URLs with a backward scan. Regression tests cover trailing slash removal, preserved interior slash runs, and URLs without trailing slashes.

Changes: Responses forward base URL normalization

Layer / File(s) Summary
Normalize and validate forward base URLs
src/adapters/openai-responses/transport.ts, tests/responses/responses-forward-transport-baseurl.test.ts, structure/providers-and-adapters.md, scripts/test-layout/layout.json, tests/fixtures/test-layout-expected.json
At transport.ts:26-37,46, a backward scan replaces the trailing-slash regular expression for noncanonical forward providers. Tests at responses-forward-transport-baseurl.test.ts:1-46 cover trailing slash removal, interior slash preservation, unchanged URLs without trailing slashes, and a 2,000-slash mid-path run. The documentation and test-layout mappings are updated.

Priority: ⬇️ Low

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to fac63

The URL normalization change appears ready to merge after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (3 skipped: 3 …
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 and concisely describes the main change: replacing trailing-slash regex normalization for forward Responses base URLs with a linear scan.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (3 skipped: 3 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Oct 19, 2026
@luvs01
luvs01 marked this pull request as ready for review October 19, 2026 05:01
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-19T05:01:53.460421Z fac6323 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@Ingwannu Ingwannu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Reviewed fac63237555cbe2730f11cdcf489231a4b2a51ff against its dev base. The backward scan preserves URL normalization while leaving canonical destination/auth/header selection unchanged; both test maps and the owning contract are updated.

Independently ran Bun 1.4.3 bun test --isolate tests/responses/responses-forward-transport-baseurl.test.ts tests/responses/openai-responses-passthrough.test.ts: 190 pass, 0 fail, in a fresh private home under the local CPU/memory/time caps. The broader full local suite was not repeated because current-head hosted run 39201522639 already completed all four selected Ubuntu shards and gates; gates job 117895368455 explicitly passes Typecheck and Privacy scan. Skipped OS suites are not platform acceptance evidence. No live provider/configuration operation or merge was performed. The advisory Codex status is review-account usage exhaustion, not a demonstrated source finding; no account/credit action was taken.

@lidge-jun

Copy link
Copy Markdown
Owner

Landed on dev as part of the replay/lifecycle bundle #7388 (squash c120eea), with your commits and Co-authored-by credit preserved. Closing as absorbed. Thank you!

@lidge-jun lidge-jun closed this Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants