Skip to content

fix(provider-usage): prefer proxy-aware fetch for Codex usage loads#78753

Closed
mgustimz wants to merge 7 commits into
openclaw:mainfrom
mgustimz:fix/codex-provider-usage-proxy-env
Closed

fix(provider-usage): prefer proxy-aware fetch for Codex usage loads#78753
mgustimz wants to merge 7 commits into
openclaw:mainfrom
mgustimz:fix/codex-provider-usage-proxy-env

Conversation

@mgustimz

@mgustimz mgustimz commented May 7, 2026

Copy link
Copy Markdown

Summary

When HTTP_PROXY/HTTPS_PROXY env vars are set, Codex provider usage fetches fail with fetch failed because loadProviderUsageSummary() didn't respect env proxy settings when an explicit fetch wasn't provided.

Root cause

In src/infra/provider-usage.load.ts, the fetch function was resolved as:

const fetchFn = resolveFetch(opts.fetch);

This bypasses env proxy settings. When direct Node fetch to chatgpt.com times out (but an HTTP proxy is available and configured in env), the usage call would consistently fail.

Fix

Changed to check env proxy when no explicit fetch is supplied:

const fetchFn = opts.fetch != null
  ? resolveFetch(opts.fetch)
  : resolveProxyFetchFromEnv(env) ?? resolveFetch(opts.fetch);

Priority: explicit fetch override > env proxy > global fetch.

resolveProxyFetchFromEnv() already exists in ./net/proxy-fetch.ts and is used in other places (e.g., openrouter-model-capabilities.ts:188, runner.entries.ts:606). This aligns the provider-usage path with existing patterns.

Changes

Testing

  • prefers proxy-aware fetch from env when HTTP_PROXY is set and no explicit fetch is supplied
  • falls back to opts.fetch when no proxy env is set

Fixes #78714

When HTTP_PROXY/HTTPS_PROXY env vars are set, Codex provider usage fetches
were failing with 'fetch failed' because loadProviderUsageSummary() only
used resolveFetch(opts.fetch) which doesn't respect env proxy settings.

Now resolves proxy-aware fetch from env first (via resolveProxyFetchFromEnv)
before falling back to the explicitly-provided fetch or global fetch.

Fixes openclaw#78714
@openclaw-barnacle openclaw-barnacle Bot added size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 7, 2026
@clawsweeper

clawsweeper Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 1, 2026, 1:07 AM ET / 05:07 UTC.

Summary
Review failed before ClawSweeper could summarize the requested change.

PR surface: Source +4, Tests +19. Total +23 across 2 files.

Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path.

Review metrics: none identified.

Merge readiness
Overall: 🌊 off-meta tidepool
Proof: 🌊 off-meta tidepool
Patch quality: 🌊 off-meta tidepool
Result: rating does not apply to this item.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] No close action taken because the review did not complete.

Maintainer options:

  1. Decide the mitigation before merge
    Retry the Codex review after fixing the execution failure.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] Review did not complete, so no work-lane recommendation was made.
Review details

Best possible solution:

Retry the Codex review after fixing the execution failure.

Do we have a high-confidence way to reproduce the issue?

Unclear. The review failed before ClawSweeper could establish a reproduction path.

Is this the best way to solve the issue?

Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction.

AGENTS.md: unclear because the file could not be read completely.

Codex review notes: model gpt-5.5, reasoning high; reviewed against d925249ac086.

Label changes

Label justifications:

  • rating: 🌊 off-meta tidepool: Overall readiness is 🌊 off-meta tidepool; proof is 🌊 off-meta tidepool and patch quality is 🌊 off-meta tidepool.
Evidence reviewed

PR surface:

Source +4, Tests +19. Total +23 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 5 1 +4
Tests 1 19 0 +19
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 24 1 +23

What I checked:

  • failure reason: codex execution failed.
  • codex failure detail: Codex review failed for this PR with exit 1.
  • codex stdout: Per-item Codex failure; continuing with the rest of the shard.

Likely related people:

  • unknown: Codex failed before it could trace repository history. (role: review did not complete; confidence: low)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

…ence

- Test that proxy-aware fetch is used when HTTP_PROXY/HTTPS_PROXY env vars are set
- Test that opts.fetch is still used as fallback when no proxy env is set
- Updated existing 'throws when fetch is unavailable' test to pass env: {} to avoid proxy interference
…nValue

TypeScript expects Promise<ProviderUsageSnapshot | null | undefined> but
mockReturnValue(null) gives type null directly.
@mgustimz
mgustimz force-pushed the fix/codex-provider-usage-proxy-env branch 2 times, most recently from 6819a8b to 7c02c54 Compare May 7, 2026 06:26
…entry

- Priority: explicit fetch > env proxy > global fetch (P2 fix)
- Add CHANGELOG.md entry for openclaw#78714 (P3 fix)
- Update test to reflect explicit fetch takes precedence
- Remove test that assumed proxy env bypasses opts.fetch
@mgustimz
mgustimz force-pushed the fix/codex-provider-usage-proxy-env branch 2 times, most recently from 8dd498b to 8cc0a27 Compare May 7, 2026 08:36
@mgustimz
mgustimz force-pushed the fix/codex-provider-usage-proxy-env branch from 8cc0a27 to a9c2a88 Compare May 7, 2026 08:38
@barnacle-openclaw

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@barnacle-openclaw barnacle-openclaw Bot added the stale Marked as stale due to inactivity label May 31, 2026
@clawsweeper clawsweeper Bot added the rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. label May 31, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jun 1, 2026
@mgustimz mgustimz closed this Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Codex provider usage ignores proxy env and reports fetch failed

1 participant