Skip to content

refactor(gateway): one owner for the trailing-slash trim - #3047

Merged
oscharko merged 1 commit into
devfrom
chip/trailing-slash-owner
Aug 9, 2026
Merged

refactor(gateway): one owner for the trailing-slash trim#3047
oscharko merged 1 commit into
devfrom
chip/trailing-slash-owner

Conversation

@oscharko

@oscharko oscharko commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

The LiteLLM production audit fixed a real 404 (a base URL ending in / produced //chat/completions) by adding the same inline expression — x.endsWith("/") ? x.slice(0, -1) : x — at ten sites across seven files: the openai and embedding adapters, the readiness probe, and the realtime, rerank, speech-to-text and text-to-speech adapters (the last four carry two each). CodeRabbit counted seven on #3042; the sweep found ten.

They now route through trimTrailingSlash in config.ts, beside the other URL helpers, so the normalization rule has a single owner.

Two deliberate choices:

  • Behavior is identical by construction — the helper is the expression. normalizeBaseUrl and validateBaseUrl are untouched; this is not a normalizer.
  • The helper stays package-internal (not re-exported from index.ts), so the root package-surface contract is unchanged. Only adapters inside the package need it.

Verification

  • A dedicated suite pins both branches plus the doubled-slash and empty-string edges; openai-adapter.test.ts gains the no-slash branch beside its existing trim pin.
  • Blast-radius proof (the point of consolidating): replacing the helper body with an unconditional slice(0, -1) turns 13 tests across 8 files red — before, the same sabotage at one inline site would have failed only that site's own test. Restored by exact inverse afterwards.
  • 1047/1047 model-gateway tests, tsc -b across three packages, repo ESLint, prettier, npm run gates:sonar PASS.

Update-Impact

Pure refactor: no behavioral change, no surface change, no migration.

🤖 Generated with Claude Code

…w-up)

The LiteLLM production audit added the same inline expression at ten sites
across seven files (openai, embedding, readiness probe, realtime x2, rerank,
stt x2, tts x2). They route through trimTrailingSlash in config.ts now, next
to the other URL helpers, so the rule has a single owner. Behavior is
identical by construction — the helper IS the expression — and it stays
package-internal (not re-exported from index.ts), so the root package
surface is unchanged.

Coverage: a dedicated helper suite pins both branches plus the doubled-slash
and empty-string edges, and openai-adapter.test.ts gains the no-slash branch
beside its existing trim pin. Blast-radius proof re-run on this rebase:
replacing the helper body with an unconditional slice(0, -1) turns 13 tests
across 8 files red, restored by exact inverse. 1047/1047, tsc across three
packages, eslint, prettier, sonar PASS.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@oscharko
oscharko temporarily deployed to keiko-for-quality August 9, 2026 00:56 — with GitHub Actions Inactive
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@oscharko, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 58 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fb062c3c-0bee-459b-876c-fbdd4cf55396

📥 Commits

Reviewing files that changed from the base of the PR and between 186d5eb and 7a3c854.

📒 Files selected for processing (10)
  • packages/keiko-model-gateway/src/config.ts
  • packages/keiko-model-gateway/src/openai-adapter.test.ts
  • packages/keiko-model-gateway/src/openai-adapter.ts
  • packages/keiko-model-gateway/src/openai-embedding-adapter.ts
  • packages/keiko-model-gateway/src/readiness-probe.ts
  • packages/keiko-model-gateway/src/realtime-voice-adapter.ts
  • packages/keiko-model-gateway/src/rerank-adapter.ts
  • packages/keiko-model-gateway/src/speech-to-text-adapter.ts
  • packages/keiko-model-gateway/src/text-to-speech-adapter.ts
  • packages/keiko-model-gateway/src/url-join.test.ts

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.

@keiko-for-quality

Copy link
Copy Markdown

Keiko for Quality — run summary

COMPLETE · head 7a3c854 · 2026-08-09T00:56:20Z · engine v1.8.4 · action 8aafc617614f06d9c90be6fb32fda112ccc1cf78

Metric Count
Total paths 10
Reviewable 10
Excluded 0
Mechanically clean 0
Critical pointer changes (content not reviewable) 0
Replayed from cache 0
Cache miss (path-set shape changed) 0
Freshly reviewed 10
Findings published 0
Suppressed (intra-run duplicate) 0
Suppressed (exact duplicate) 0
Suppressed (similar) 0
Suppressed (dispositioned) 0
Suppressed (outdated recurrence) 0
Rejected (sanitization) 0
Rejected (placement) 0
Read-back failures 0
API failures 0
Duration (s) 13

Budget: 2607020 tokens allotted, 67978 reported

Recent runs

  • 7a3c854 · complete · fresh 10 · replayed 0 · 13s

@oscharko
oscharko temporarily deployed to keiko-for-quality August 9, 2026 00:56 — with GitHub Actions Inactive
@sonarqubecloud

sonarqubecloud Bot commented Aug 9, 2026

Copy link
Copy Markdown

@oscharko
oscharko merged commit 17dcbb3 into dev Aug 9, 2026
29 checks passed
@oscharko
oscharko deleted the chip/trailing-slash-owner branch August 9, 2026 01:38
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.

1 participant