Repository navigation
Description
Client or integration
Other
Area
Other
Summary
The test suite sends real network requests, mostly carrying fixture credentials, to real provider hosts. A read-only run of the full suite on dev 950b7d9 (all 3,304 test files, with an untracked logging preload that logs and never blocks) found 43 test files making 230 outbound attempts to 9 real hosts. 224 of those attempts carry a credential: bearer tokens, plus 5 OAuth refresh-grant bodies to auth.openai.com.
Every credential observed is a fixture, either a literal in the test or one built by test helpers (for example fakeChatGptJwt). None came from the developer's environment or keychain on the run host (HOME was sandboxed and no provider key variables were set). Each leak is a request getting past a mock: no test contacts a real host on purpose. The real servers answered 401 or 400, so the HTTP requests did reach them.
The problems this causes:
- fixture tokens are sent to third-party production endpoints;
- tests depend on network reachability and latency (test(server): keep the live-cancel pool fixture quota prime off the network #8828 was one flake from this class: a quota-prime refresh to auth.openai.com outlived a test's cleanup on a stalled runner network);
- a future test, or a developer machine with real provider variables set, could send a real credential.
Hosts, with the number of test files reaching each: chatgpt.com (37, mostly wss), auth.openai.com (3), api.githubcopilot.com (2), api.anthropic.com, api.minimax.io, api.minimaxi.com, api.deepseek.com, opencode.ai and api.together.xyz (1 each).
Six source paths account for every leaking file:
- WebSocket upstream (
src/server/responses/codex-ws-session.ts:55): 25 files. They mockfetchbut notWebSocket. - Quota probe (
src/codex/quota-query-backoff.ts:137,/backend-api/wham/usage): 13 files. - OpenAI refresh (
src/codex/account-store.ts:1408,auth.openai.com/oauth/token):codex-account-threshold-api,chat-completions-pool-modeandnative-profile-startup. - Model entitlements (
src/codex/model-entitlements.ts:728):management-client-config-routeandnative-model-toggle. src/lib/pinned-http.ts:414usesnode:httpsdirectly, soglobalThis.fetchmocks never see/models:github-copilot-stream-contract,gpt61-terra-provider-rows,minimax-combo-image-input,management-provider-validationandcodex-retained-root-serialization(abun --evalchild).- Mocks that pass other URLs through to the real fetch:
oauth-code-login(its token mock lets/api/oauth/profilethrough,src/oauth/anthropic-identity.ts:34) andtests/helpers/native-profile-startup-child.ts:88.
Proposed fix (owner decision 2026-11-16: investigate and propose, with no code change in this round):
- Fix the six paths first with shared stubs, chiefly a
WebSocketstub helper and a pinned-http seam that respects test transport. - Then add a guard in
tests/preload.ts. It hooks fetch, WebSocket,net.Socket.connect(which covers TLS andnode:http(s)),ClientRequestandhttp2.connect, and refuses a non-loopback target as a connection failure (a rejected fetch or a WebSocket error event) rather than a thrown exception. - Always allowed:
- loopback (
127.0.0.0/8,::1,localhost,*.localhost,0.0.0.0); .test,.exampleand.invalidnames, which fail at DNS and about 20 files rely on that;- Unix sockets and
ws+unix; - a fetch whose
proxyoption points at loopback (8 files use this).
- loopback (
- Allowlist of real hosts: empty. One opt-in helper (for example
allowOwnInterfaceAddressesForTest()) is needed forloopback-listener-integration, which deliberately connects to the machine's own interface address. - Child processes:
[test] preloaddoes not reach child processes, so the guard must be passed explicitly tonative-profile-startup-child.tsand thebun --evalchildren.
Reproduction
- Check out dev 950b7d9.
- Add an untracked preload that wraps
globalThis.fetch,WebSocket,net.Socket.prototype.connect,http.ClientRequestandhttp2.connect. Have it log one line per attempt to a non-loopback, non-.test/.example/.invalidhost: test file, method, host, path without query, and credential kind. Log header names only, never values. - Run
bun run test --preload <logger>. Add a temporary top-levelpreloadinbunfig.tomlsobunchild processes are logged too, then revert it. Run any files cut off by the 900 s lane budget, and the serial files, in a second pass with the same logger. - Group the log by test file and host.
Version
dev 950b7d9
Operating system
Linux (pen-cc-01, Ubuntu); macOS and Windows not run
Provider and model
N/A (test suite)
Logs or error output
Per-file results (credential source = where the value comes from in the test):
| Test file | Host(s) | Credential kind | Attempts | Credential source |
|---|---|---|---|---|
| claude-integration/claude-messages-endpoint | chatgpt.com | bearer | 2 | literal |
| claude-integration/claude-native-affinity | chatgpt.com (wss) | bearer | 9 | literal |
| claude-integration/claude-native-fast-1m-ingress | chatgpt.com (wss) | bearer | 2 | literal |
| claude-integration/claude-outbound | chatgpt.com (wss) | none | 2 | — |
| codex-integration/bearer-admission-routed-provider | chatgpt.com (wss) | bearer | 3 | literal, test JWT |
| codex-integration/codex-account-threshold-api | chatgpt.com, auth.openai.com | bearer, refresh grant | 4 | literal |
| codex-integration/codex-retained-root-serialization (child) | api.together.xyz | bearer | 2 | literal |
| codex-integration/issue-452-empty-503 | chatgpt.com (wss) | bearer | 1 | literal |
| codex-integration/issue-702-expired-replay-state | chatgpt.com (wss) | bearer | 7 | fakeChatGptJwt |
| codex-integration/main-account-hard-lock-auth | chatgpt.com | bearer | 1 | literal |
| codex-integration/native-model-toggle | chatgpt.com | bearer | 1 | literal |
| codex-integration/native-profile-crash-boundaries (child) | chatgpt.com | bearer | 6 | literal |
| codex-integration/native-profile-drain-server | chatgpt.com (wss) | bearer | 2 | literal |
| codex-integration/native-profile-startup (child) | chatgpt.com, auth.openai.com | bearer, refresh grant | 16 | literal |
| oauth/oauth-code-login | api.anthropic.com | bearer | 15 | token-mock literal |
| providers/github-copilot/github-copilot-stream-contract | api.githubcopilot.com | bearer | 1 | literal |
| providers/gpt61-terra-provider-rows | api.githubcopilot.com | bearer | 3 | literal |
| providers/minimax-combo-image-input | api.minimax.io, api.minimaxi.com | bearer | 2 | literal |
| responses/agent-assertion-routes | chatgpt.com | bearer | 1 | literal |
| responses/chat-completions-pool-mode | chatgpt.com, auth.openai.com | bearer, refresh grant | 4 | literal |
| responses/chat-conversation-affinity | chatgpt.com (wss) | bearer | 22 | built in test |
| responses/codex-0164-request-compat | chatgpt.com (wss) | bearer | 9 | fakeChatGptJwt |
| responses/reasoning-retention-routing | chatgpt.com (wss) | bearer | 6 | fakeChatGptJwt |
| responses/reasoning-retention-v2 | chatgpt.com (wss) | bearer | 1 | literal |
| responses/responses-compaction-override | chatgpt.com (wss) | bearer | 14 | fakeChatGptJwt |
| responses/responses-inbound-store-default | chatgpt.com (wss) | none | 3 | — |
| responses/responses-native-main-refresh | chatgpt.com (wss) | bearer | 1 | literal |
| responses/responses-native-ultra-effort-wire | chatgpt.com (wss) | bearer | 1 | literal |
| responses/responses-opaque-blob-recovery | chatgpt.com (wss) | bearer | 2 | literal |
| responses/responses-retained-reasoning-stream-recovery | chatgpt.com (wss) | bearer | 11 | literal |
| responses/responses-self-named-namespace-scrub | chatgpt.com (wss) | bearer | 9 | literal |
| responses/ws-upstream | chatgpt.com (wss) | bearer | 1 | literal |
| routing/fastwire-response-authority | chatgpt.com (wss) | none | 1 | — |
| routing/subagent-fallback-handle-responses | chatgpt.com | bearer | 9 | literal |
| server/management-client-config-route | chatgpt.com | bearer | 1 | literal |
| server/management-provider-validation | api.deepseek.com, opencode.ai | bearer | 16 | literal |
| server/server-auth | chatgpt.com (wss) | bearer | 12 | literal |
| server/server-combo-failover-e2e | chatgpt.com | bearer | 5 | literal |
| server/server-images | chatgpt.com | bearer | 1 | fakeChatGptJwt |
| server/server-live | chatgpt.com | bearer | 2 | fakeChatGptJwt |
| server/server-live-existing-call | chatgpt.com | bearer | 2 | fakeChatGptJwt |
| server/server-search | chatgpt.com | bearer | 1 | literal |
| server/turn-state-handles | chatgpt.com (wss) | bearer | 16 | fakeChatGptJwt |
Left out because they never contact a real host:
- 58 attempts sent through a fetch
proxyoption pointed at 127.0.0.1; loopback-listener-integrationconnecting to the machine's own interface address;- three files that only resolve names in DNS.
The logger caused no failures: 13 files that failed only in the loaded first pass passed on rerun with the logger (544 tests, 0 failures).
Screenshots and supporting files
No response
Redacted configuration
No response
Checks
- I searched existing issues and documentation.
- I removed secrets, tokens, account details, request credentials, and personal data.
NOT RUN: macOS and Windows (the Claude Keychain reader was not exercised). Also not covered: a host with real provider key variables set; non-Bun child processes (git, curl, codex binaries); bun children started outside the repo; Bun.fetch; and WebSocket handshake results, which were not hooked.
Activity
fix: R5 platform and test-hygiene lane (zh-CN/ko-KR checked stop, Win…