GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(proxy): stop empty 503 bodies becoming Codex Unknown error (#452) by Wibias · Pull Request #463 · lidge-jun/opencodex

Conversation

@Wibias

@Wibias Wibias commented Jul 25, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary

  • Never relay empty or non-JSON ChatGPT passthrough error bodies; wrap them so Codex always gets a non-empty error.message instead of Unknown error.
  • Make drain 503 responses JSON (server_is_overloaded) with Retry-After: 5.
  • Add debugProviderDiagnostic hooks to openai-chat so ocx debug provider logs captures Xiaomi/openai-chat traffic.
  • Focused regression tests for 503 from /v1/responses via Codex even though direct proxy curl to same endpoint returns 200 OK (Xiaomi MiMo provider, openai-chat adapter) #452.

Test plan

  • bun run typecheck
  • bun test ./tests/issue-452-empty-503.test.ts ./tests/shutdown-drain.test.ts ./tests/debug.test.ts
  • Reproduce 503 from /v1/responses via Codex even though direct proxy curl to same endpoint returns 200 OK (Xiaomi MiMo provider, openai-chat adapter) #452: Codex against a routed openai-chat provider; confirm failures (if any) show a real message, and ocx debug provider on + logs -f shows openai-chat request lines

Summary by CodeRabbit

  • Bug Fixes
    • Improved error responses when upstream services return empty or unsuccessful responses.
    • Preserved relevant status details and validated retry timing information.
    • Standardized shutdown responses as JSON and included retry guidance.
    • Improved handling of streaming errors and truncated streams.
  • Diagnostics
    • Added optional debug logging for outbound requests and stream failures while redacting sensitive credentials.
  • Tests
    • Added coverage for upstream errors, shutdown behavior, retry headers, and diagnostic redaction.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Wibias
fix(proxy): stop surfacing empty 503 bodies as Codex Unknown error
a17e50b
Wrap empty/non-JSON ChatGPT passthrough failures and drain responses as JSON so Codex always gets error.message. Also add openai-chat provider debug diagnostics for #452.
@Wibias
Wibias requested review from Ingwannu and lidge-jun as code owners July 25, 2026 21:51
@github-actions github-actions Bot added the bug Something isn't working label Jul 25, 2026
@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR standardizes empty-body upstream failures and server-draining responses as JSON 503/429-compatible envelopes, preserves validated retry headers, and adds redacted OpenAI chat request and stream diagnostics with unit and integration coverage.

Changes

Error handling and diagnostics

Layer / File(s) Summary
Upstream passthrough error handling
src/server/responses/passthrough-error.ts, src/server/responses/core.ts, tests/issue-452-empty-503.test.ts
Non-2xx upstream responses are handled before normal passthrough processing. Empty bodies become JSON errors, valid Retry-After values are preserved, combo failures use typed envelopes, and passthrough behavior is tested across response and chat-completion routes.
Draining response centralization
src/server/index.ts, tests/issue-452-empty-503.test.ts
Draining exits use a shared CORS-enabled JSON 503 response with Retry-After: 5 across HTTP and WebSocket routes, with integration coverage.
OpenAI chat request and stream diagnostics
src/adapters/openai-chat.ts, tests/issue-452-empty-503.test.ts
Debug logging records redacted request metadata, inline upstream stream errors, and truncated streams while preserving terminal error events. Tests verify host logging and sensitive-path redaction.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ResponsesCore
  participant Upstream
  participant ErrorFormatter
  Client->>ResponsesCore: Send passthrough request
  ResponsesCore->>Upstream: Fetch upstream response
  Upstream-->>ResponsesCore: Return non-2xx status and body
  ResponsesCore->>ErrorFormatter: Format status, body, and retry headers
  ErrorFormatter-->>Client: Return structured JSON error
Loading

Possibly related PRs

  • lidge-jun/opencodex#339: Both changes modify OpenAI chat stream termination and finish_reason handling.
  • lidge-jun/opencodex#379: Both changes update draining behavior for server routes.

Suggested reviewers: lidge-jun, ingwannu

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main fix: empty 503 error bodies are normalized so Codex no longer surfaces Unknown error.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Wibias Wibias mentioned this pull request Jul 25, 2026
503 from /v1/responses via Codex even though direct proxy curl to same endpoint returns 200 OK (Xiaomi MiMo provider, openai-chat adapter) #452
Closed
2 tasks done
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Wibias added 2 commits July 26, 2026 00:02
@Wibias
fix(proxy): only wrap empty passthrough error bodies
fc3870a
Preserve non-empty upstream 400/5xx bytes and headers so Codex pool-retry activation and Claude Retry-After fidelity stay intact. Empty bodies still become JSON for #452.
@Wibias
fix(proxy): preserve Retry-After and redact tenant URLs in debug
fc6bc25
Normalized empty-body passthrough errors keep a validated Retry-After with application/json. openai-chat diagnostics log only the host so Cloudflare account paths never appear.
coderabbitai[bot]
coderabbitai Bot reviewed Jul 25, 2026
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/server/responses/passthrough-error.ts`:
- Around line 4-8: Extract the duplicated Retry-After validation into a shared
helper, using the existing implementation in core.ts as the single source of
truth. Remove the local sanitizedRetryAfter function from passthrough-error.ts
and import the shared helper, preserving the 128-character limit and
parseRetryAfterMs behavior for both passthrough and combo failures.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 61cb37ac-110c-472f-ad95-488b93de0053

📥 Commits

Reviewing files that changed from the base of the PR and between 4e5d010 and fc6bc25.

📒 Files selected for processing (5)
  • src/adapters/openai-chat.ts
  • src/server/index.ts
  • src/server/responses/core.ts
  • src/server/responses/passthrough-error.ts
  • tests/issue-452-empty-503.test.ts

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/server/responses/passthrough-error.ts
Comment on lines +4 to +8
function sanitizedRetryAfter(value: string | null | undefined, now: number): string | undefined {
const trimmed = value?.trim();
if (!trimmed || trimmed.length > 128) return undefined;
return parseRetryAfterMs(trimmed, now) !== undefined ? trimmed : undefined;
}

@coderabbitai coderabbitai Bot Jul 25, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n "sanitizedRetryAfter" -g '*.ts' -B2 -A6

Repository: lidge-jun/opencodex

Length of output: 157


🏁 Script executed:

#!/bin/bash
set -euo pipefail

git ls-files 'src/server/responses/passthrough-error.ts' 'src/**/core.ts' 'src/**/failover.ts' | sed 's#^`#FILE` #'
echo '---'
rg -n "sanitizedRetryAfter|parseRetryAfterMs|formatPassthroughUpstreamError|passthrough-error" src -g '*.ts' -A4 -B4

Repository: lidge-jun/opencodex

Length of output: 12117


Extract sanitizedRetryAfter into a shared helper. src/server/responses/core.ts:291-294 and src/server/responses/passthrough-error.ts:4-7 duplicate the same Retry-After validation. Keep one source of truth so the 128-char guard and parse behavior can’t drift between passthrough and combo failures. Import it from a shared module instead of maintaining two copies.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/server/responses/passthrough-error.ts` around lines 4 - 8, Extract the
duplicated Retry-After validation into a shared helper, using the existing
implementation in core.ts as the single source of truth. Remove the local
sanitizedRetryAfter function from passthrough-error.ts and import the shared
helper, preserving the 128-character limit and parseRetryAfterMs behavior for
both passthrough and combo failures.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Wibias
Wibias merged commit e0b7458 into lidge-jun:dev Jul 25, 2026
11 checks passed

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Jul 25, 2026
fix(providers): honor saved baseUrl for alibaba-token-plan via override + choices #459
Closed
feat(kiro): honor native END_TURN and Opus 5 native reasoning effort #460
Closed
feat(cli): add ocx opencode launcher #461
Closed
fix(router): warn when a pinned provider discards a configured baseUrl #464
Closed
fix(gui): react-doctor shared foundations #466
Merged
refactor(gui): split Combos for react-doctor #467
Merged
refactor(gui): react-doctor cleanup for Startup/Debug/Storage/Usage #468
Merged
fix(gui): restore OpenAI account setup with canonical recovery gates #469
Merged
feat(codex): add account-qualified model namespaces #426
Closed
This was referenced Jul 26, 2026
fix(proxy): preserve OpenAI cyber_policy errors end-to-end #483
Merged
fix(proxy): attach Retry-After on retryable 429s for Codex #514
Merged
@Wibias
Wibias deleted the fix/issue-452-opaque-503 branch July 27, 2026 03:53
This was referenced Jul 30, 2026
fix(providers): route GitHub Copilot Responses-only models off chat completions #746
Closed
Revert "fix(openai-chat): complete streams that end after output without terminal" #792
Merged
fix(streaming): repair sparse Responses snapshots #928
Closed
fix(anthropic): surface upstream error bodies through sidecar bridges #1020
Merged
This was referenced Aug 9, 2026
fix(providers): surface OpenCode Zen short-window rate limits #1330
Merged
feat(chat): native chat->chat for openai-chat providers (#1467) #1569
Closed
[Bug] Bun.serve has no maxRequestBodySize: >128 MiB /v1/responses bodies get an empty-body 413 that Codex renders as "Unknown error" #1601
Closed
This was referenced Aug 15, 2026
Pacing queue overload surfaces as 502 upstream_error instead of retryable 429 on fetchResponse and rebuildAndRefetch paths #1790
Closed
[BUG] Codex requests continuously return 502 Bad Gateway after ocx service install in Windows 10 + WSL #2107
Closed
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
@Wibias
Merge pull request lidge-jun#463 from Wibias/fix/issue-452-opaque-503
21ba710
fix(proxy): stop empty 503 bodies becoming Codex Unknown error (lidge-jun#452)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments
@chatgpt-codex-connector chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] left review comments
@lidge-jun lidge-jun Awaiting requested review from lidge-jun lidge-jun is a code owner
@Ingwannu Ingwannu Awaiting requested review from Ingwannu Ingwannu is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

bug Something isn't working

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@Wibias
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.