Repository navigation
fix(relay): normalize bifrost errors, remap credential 404, fix analytics - #10797
Merged
Merged
Conversation
…tics - Normalize non-OK Bifrost upstream responses through parseUpstreamError + buildErrorBody/sanitizeErrorMessage so plain-text/HTML errors are wrapped into valid OpenAI JSON instead of leaking raw bodies (invalid character 'd'). - handleNoCredentials() now takes an isCombo flag: single-model requests remap the combo 404 to 401/503 so direct clients no longer see a misleading 'No active credentials' 404. Combo routing keeps 404 for fall-through. - recordUsage() now records any non-2xx upstream status as 'error' rather than 'success' (was status < 500), fixing 4xx analytics misclassification. Adds/updates tests covering all three scenarios.
…sponse The new !upstream.ok error path copies upstream.headers (which can carry a content-length/content-encoding/transfer-encoding for the ORIGINAL upstream body) onto the freshly re-serialized JSON error Response, causing a byte-length mismatch. Route the headers through stripStaleEncodingHeaders() before serializing the error body, and add a regression test that mocks an upstream Response with an explicit content-length header. Co-authored-by: OPX-Aminul <305739020+OPX-Aminul@users.noreply.github.com>
5 tasks
diegosouzapw
added a commit
that referenced
this pull request
Aug 20, 2026
giauphan
pushed a commit
to giauphan/OmniRoute
that referenced
this pull request
Aug 20, 2026
…zapw#10722, diegosouzapw#10797) + pre-existing chatBodyAdmission.ts drift Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
…del requests This PR's own handleNoCredentials change remaps the leaked combo-fallback 404 to 401 for non-combo (single-model) requests, but left 5 pre-existing tests asserting the old 404 for exactly that single-model path: vscode-token-routes.test.ts (both routes), chat-route-coverage.test.ts, chat-pipeline.test.ts (both cases), combo-routing-e2e.test.ts (unmapped-model case), llama-cpp-provider.test.ts. Combo-routing tests that legitimately expect 404 (isCombo=true fall-through) are untouched. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
backryun
added a commit
to backryun/OmniRoute
that referenced
this pull request
Aug 21, 2026
…souzapw#10797 diegosouzapw#10797 (bc6129b) remapped credential-lookup misses for unknown providers from 404 to 401, so the preserve-mode fall-through request in chat-previous-response-id-preserve-mode.test.ts now returns 401 instead of 404. The assertion's real contract — the error is NOT the virtualization's previous_response_not_found rejection — is unchanged; only the expected status moves with the remap. 2/2 green.
backryun
added a commit
to backryun/OmniRoute
that referenced
this pull request
Aug 21, 2026
diegosouzapw#10797 (bc6129b) remapped credential-lookup misses for unknown providers from 404 to 401. The two schema-pass-through assertions in chat-early-schema-validation-6412.test.ts still expected the old 404; their real contract (schema validation runs first, provider lookup after, no false 400) is unchanged. 7/7 green.
backryun
added a commit
to backryun/OmniRoute
that referenced
this pull request
Aug 21, 2026
…souzapw#10797 diegosouzapw#10797 (bc6129b) remapped credential-lookup misses for unknown providers from 404 to 401, so the preserve-mode fall-through request in chat-previous-response-id-preserve-mode.test.ts now returns 401 instead of 404. The assertion's real contract — the error is NOT the virtualization's previous_response_not_found rejection — is unchanged; only the expected status moves with the remap. 2/2 green.
backryun
added a commit
to backryun/OmniRoute
that referenced
this pull request
Aug 21, 2026
diegosouzapw#10797 (bc6129b) remapped credential-lookup misses for unknown providers from 404 to 401. The two schema-pass-through assertions in chat-early-schema-validation-6412.test.ts still expected the old 404; their real contract (schema validation runs first, provider lookup after, no false 400) is unchanged. 7/7 green.
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…zapw#10722, diegosouzapw#10797) + pre-existing chatBodyAdmission.ts drift Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…tics (diegosouzapw#10797) Merged — the 5 pre-existing tests that broke from this PR's intentional 404→401 remap (single-model no-credentials) are now realigned to the new contract. Thanks!
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Recreated from #10785 (OPX-Aminul) — the fork's push access was not available for the mandatory pre-merge fix, so this branch was cut fresh from
release/v3.8.50and carries the original commit unmodified plus the required follow-up fix on top.Originally-proposed-by: @OPX-Aminul in #10785
What this does
content-length/content-encoding/transfer-encodingheaders before serializing the JSON error body, so the response headers don't lie about the freshly-serialized body's real size/encoding — with a regression test that mocks a real upstreamResponsecarrying those headers.Test plan
node --import tsx/esm --test tests/unit/api/v1/relay-completions-errors.test.ts— 4/4 passnpm run typecheck:core— cleannpx eslinton touched files — clean