Skip to content

fix(rate-limits): pass configured proxies to Codex fetchers (#11752) - #11862

Closed
rodboev wants to merge 2 commits into
stablyai:mainfrom
rodboev:pr/rate-limit-proxy-env
Closed

rodboev wants to merge 2 commits into
stablyai:mainfrom
rodboev:pr/rate-limit-proxy-env

Conversation

@rodboev

@rodboev rodboev commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Codex rate-limit RPC and PTY subprocesses now receive the configured proxy environment.
  • The provider clones inherited variables, gives explicit settings precedence, preserves CODEX_HOME and TERM, exports proxy values inside WSL, and leaves the parent environment unchanged.

Closes #11752.

Screenshots

No visual change

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions

Focused validation run in this session:

  • pnpm exec vitest run --config config/vitest.config.ts src/main/rate-limits/codex-fetcher.test.ts src/main/rate-limits/codex-fetcher-proxy-env.test.ts src/shared/network-proxy.test.ts (30 passed)
  • pnpm run typecheck:node
  • pnpm exec oxlint src/main/rate-limits/codex-fetcher.ts src/main/rate-limits/codex-fetcher.test.ts src/main/rate-limits/codex-fetcher-proxy-env.test.ts src/main/rate-limits/service.ts src/main/rate-limits/service.test.ts
  • pnpm exec oxfmt --check src/main/rate-limits/codex-fetcher.ts src/main/rate-limits/codex-fetcher.test.ts src/main/rate-limits/codex-fetcher-proxy-env.test.ts src/main/rate-limits/service.ts src/main/rate-limits/service.test.ts
  • pnpm run check:max-lines-ratchet
  • git diff --check
  • src/main/rate-limits/service.test.ts was also run; seven existing Claude PTY expectation cases fail on Windows because the test expects Linux values (allowUsagePanelSupplement: true), while the unchanged production guard correctly returns false on win32.

AI Review Report

The change is limited to Codex rate-limit subprocess environment construction and service wiring. RPC and PTY use the same inherited-environment clone and configured proxy merge. WSL receives the proxy through the existing shell-quoting path; host CODEX_HOME stripping and PTY TERM behavior remain intact. No UI, network client, provider selection, or new subprocess path changed.

Security Audit

Configured proxy values pass through the existing normalized proxy helper, which preserves credential handling and bypass normalization. Values are shell-quoted for WSL and are not logged. The parent process.env is never mutated, and no new network or credential source is introduced.

Notes

Validated against origin/main at a53c5d3fb07ef00bbe42e75609310436ed95a541. The base regression run failed the configured RPC and PTY proxy assertions; the head run passed all 30 focused tests. Related PR #11662 covers invalid RPC fallback, not proxy environment merging.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e28023ab-0e77-4839-9ac1-3a52d422b7c8

📥 Commits

Reviewing files that changed from the base of the PR and between 5738d61 and 994d47c.

📒 Files selected for processing (5)
  • src/main/rate-limits/codex-fetcher-proxy-env.test.ts
  • src/main/rate-limits/codex-fetcher.test.ts
  • src/main/rate-limits/codex-fetcher.ts
  • src/main/rate-limits/service.test.ts
  • src/main/rate-limits/service.ts

📝 Walkthrough

Walkthrough

Codex rate-limit fetching now accepts network proxy settings. The settings are passed through inactive-account, reset-refresh, full-refresh, and Codex-only service paths. WSL commands export configured proxy variables. RPC and PTY subprocesses use a shared child-environment builder. Tests cover configured and inherited proxy values, parent environment preservation, WSL command exports, and PTY fallback propagation.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: passing configured proxies to Codex rate-limit fetchers.
Description check ✅ Passed The description covers all required sections and documents focused validation, review, security, and platform notes, but lacks an explicit full macOS/Linux/Windows checklist confirmation.
Linked Issues check ✅ Passed The implementation propagates configured proxy settings to both Codex RPC and PTY fallback environments and verifies precedence, WSL export, and environment preservation [#11752].
Out of Scope Changes check ✅ Passed All production and test changes directly support configured proxy propagation for Codex rate-limit RPC and PTY paths; no unrelated scope is evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

@greptile-apps

greptile-apps Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR fixes proxy settings not being forwarded to Codex rate-limit subprocesses (RPC and PTY). A new buildCodexChildEnv helper centralises subprocess environment construction, and all four fetchCodexRateLimits call sites in service.ts now receive networkProxySettings from the resolver.

  • buildCodexChildEnv merges the parent environment, configured proxy vars (via buildConfiguredProxyEnv), and CODEX_HOME in the correct precedence order for both WSL and non-WSL paths.
  • WSL shell commands receive proxy values through export KEY=value statements injected by the updated buildWslCodexCommand signature; process.env is never mutated.
  • Three new tests in codex-fetcher-proxy-env.test.ts and two updated WSL tests cover override, inheritance, and PTY scenarios.

Confidence Score: 5/5

Safe to merge — the change is narrowly scoped to subprocess environment construction and service wiring, with no mutations to process.env and no new network or credential sources.

The new buildCodexChildEnv helper correctly handles all four environment-construction cases (WSL/non-WSL × RPC/PTY), all service call sites were updated, parent process.env is never mutated, and the three new focused tests plus two updated WSL tests validate the proxy injection end-to-end.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
src/main/rate-limits/codex-fetcher.ts Adds buildCodexChildEnv helper to centralise subprocess env construction, merging parent env, configured proxy vars, and CODEX_HOME; injects proxy exports into WSL shell commands via proxyEnv option on buildWslCodexCommand; both RPC and PTY paths use the new helper correctly.
src/main/rate-limits/service.ts Threads networkProxySettings: this.networkProxySettingsResolver?.() into all four fetchCodexRateLimits call sites; straightforward wiring change with no logic alterations.
src/main/rate-limits/codex-fetcher-proxy-env.test.ts New test file covering three proxy scenarios: configured proxy overrides parent env for RPC, empty proxy preserves parent env without injecting empty keys, and configured proxy reaches PTY spawn env.
src/main/rate-limits/codex-fetcher.test.ts Extends two existing WSL RPC tests with networkProxySettings and asserts the proxy export statement appears in the generated WSL shell command.
src/main/rate-limits/service.test.ts Adds assertion that fetchCodexRateLimits is called with networkProxySettings alongside the existing fetchClaudeRateLimits assertion in the refresh test.

Sequence Diagram

sequenceDiagram
    participant S as RateLimitService
    participant CF as codex-fetcher
    participant NP as network-proxy
    participant C as Child Process (RPC/PTY)

    S->>S: networkProxySettingsResolver()
    S->>CF: "fetchCodexRateLimits({ networkProxySettings })"

    alt WSL path (codexHomePath is UNC)
        CF->>NP: buildConfiguredProxyEnv(settings)
        NP-->>CF: "{ HTTP_PROXY, HTTPS_PROXY, ... }"
        CF->>CF: "buildWslCodexCommand(path, args, { proxyEnv })"
        note over CF: injects export HTTP_PROXY=... into WSL sh -c script
        CF->>NP: buildConfiguredProxyEnv(settings) via buildCodexChildEnv
        NP-->>CF: "{ HTTP_PROXY, HTTPS_PROXY, ... }"
        CF->>C: "spawn(wsl.exe, [...], { env: buildCodexChildEnv(...) })"
    else Non-WSL path
        CF->>NP: buildConfiguredProxyEnv(settings) via buildCodexChildEnv
        NP-->>CF: "{ HTTP_PROXY, HTTPS_PROXY, ... } or {}"
        CF->>C: "spawn(codex, args, { env: buildCodexChildEnv(...) })"
    end

    C-->>CF: rate limit data
    CF-->>S: ProviderRateLimits
Loading

Reviews (2): Last reviewed commit: "refactor(rate-limits): build proxy env o..." | Re-trigger Greptile

Comment thread src/main/rate-limits/codex-fetcher.ts Resolved
@rodboev

rodboev commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@onetom

onetom commented Sep 17, 2026

Copy link
Copy Markdown

Related PR, with a bit broader scope:
#19931
(also waiting for maintainer approval)

@nwparker

Copy link
Copy Markdown
Contributor

Thanks @rodboev for the work here. Closing as superseded: Codex usage requests now honor the configured proxy via #26942. Appreciate the contribution, and feel free to open a fresh PR against current main if you see anything still missing.

@nwparker nwparker closed this Oct 24, 2026
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.

[Bug]: Configured HTTP proxy is not propagated to Codex rate-limit subprocesses

5 participants