test: stop the suite from reading — and calling — the developer's own gateway - #97
Open
xizhuomengcontin wants to merge 1 commit into
Open
xizhuomengcontin wants to merge 1 commit into
xizhuomengcontin wants to merge 1 commit into
Conversation
… gateway
`record`, `replay`, `attach` and `compare` all resolve their upstream through
`upstreamPlan()` and `readConfig()` with no environment argument. In a test,
that reads the real `~/.config/orca/config.json`.
So on a machine where anyone has run `orca setup`, any dialect a test did not
override with `--upstream-*` resolves to that developer's gateway, and the test
sends a live request to it. The fork tests do exactly that:
fake-agent: upstream 401: {"error":{"message":"unknown provider error"}}
AssertionError: expected 2 to be greater than 2
`--upstream-anthropic` was overridden; `openai` and `openai-responses` were not,
and fell through to the configured gateway. What saved the key here is
`upstreamPlan`'s unanimity rule — origins were not all the gateway, so no
headers were attached and the request 401'd. Had the test overridden nothing,
every origin would have been the gateway and the key would have gone with it.
`compare.test.ts` had already met this and worked around it inside one
`describe`, with the diagnosis in the comment: *"Nothing to do with the
platform; CI passes only because CI has no config."* That is the whole thing —
it cannot fail in CI, by construction, so it surfaces only as a test that is
red on a contributor's machine and green on everyone else's.
vitest.setup.ts gives every worker an empty XDG_CONFIG_HOME, so no future test
has to remember. The local workaround in compare.test.ts retires into it, and
config.test.ts gains the guard that makes the setup file's failure visible:
`readConfig()` with no argument must resolve to `{}`.
I had these two down as an unexplained hang. They do not hang — under a full
suite they hit the 30s timeout, but run alone each fails in under two seconds
with the 401 above. Both pass with an isolated config home, on Windows and
independently of it.
Windows: 10 failures before, 8 after. Nothing platform-specific about either of
the two, and nothing was skipped to get there.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
🐳 OrcaCode Review
✅ No findings — nothing to flag in this PR. Great work!
OrcaCode Review — Route Smarter. Ship Safer. Spend Less.
Engine-reported: 1021 calls · 118.7M tokens · 99% cached
❤️ Share · Install OrcaCode Review
Free on GitHub — the review runs on your own OrcaRouter key. If it helped, a shout-out goes a long way.
Share: X · Reddit · LinkedIn
Follow: X · Discord · LinkedIn · OrcaRouter
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.
Orca-Code-Review — push 1
✅ no blocking findings
record,replay,attachandcompareall resolve their upstream throughupstreamPlan()andreadConfig()with no environment argument. In a test, that reads the real~/.config/orca/config.json.On a machine where anyone has run
orca setup, that file names a gateway. Any dialect a test didnot override with
--upstream-*resolves to it, and the test sends a live request to a thirdparty's host.
How it showed up
Two tests were red on my machine and green in CI:
Run alone, in 1.6 seconds:
The test passes
--upstream-anthropic <fixture>. It does not pass--upstream-openai, soresolveUpstreamfalls through toconfig.gateway.urlforopenaiandopenai-responses—in my case
http://155.103.159.98:8317, a real host.What saved the key is
upstreamPlan's unanimity rule, and it is worth naming because it wasthe only thing standing there: origins were not all the gateway, so no headers were attached and
the request came back 401. Had the test overridden nothing, every origin would have been the
gateway,
goingToGatewaywould have been true, and the developer's API key would have gone out ona request generated by
npx vitest.It is not a hang, and not a platform thing
I had previously recorded these two as an unexplained hang that survived raising the timeout to
120s. That was wrong, and the mechanism is ordinary: under a full suite they reach the 30s timeout
because everything is slow at once; run alone they fail immediately with the 401 above. Both pass
with an isolated config home, on Windows and anywhere else.
The repo already knew
compare.test.tshad met this and worked around it inside a singledescribe:That is the complete diagnosis, written down, and the fix it got covered one block. The same
fallback was meanwhile calling a real gateway from two other test files.
The change
vitest.setup.tsgives every worker an emptyXDG_CONFIG_HOME, so no future test has to remember.A real empty directory rather than a missing path, so that a test which writes a config stays out
of the developer's own.
compare.test.tsretires into it, its history kept in the commentconfig.test.tsgains the guard that makes a silent failure of the setup file loud:readConfig()with no argument must resolve to{}Tests that legitimately exercise config all pass an explicit
envobject already, so none of themare affected.
Measured
Windows, same machine and build: 10 failures before, 8 after — the two gone are exactly these,
and nothing was skipped to get there.
prettier --check,tsc --build --force,scripts/conformance.mjs(63 events, 0 failures) andscripts/fidelity.mjs --check(0 regressions) are clean.
CI cannot demonstrate this fix — it has no config, which is the point.
🤖 Generated with Claude Code