From 8d13a3f64e7ad929da823f27a73de44775e8355e Mon Sep 17 00:00:00 2001 From: Edwin Date: Tue, 25 Aug 2026 11:51:39 -0700 Subject: [PATCH] test(daemon): scrub every provider key var, not just the auto rung's MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit auto_unavailable_when_only_a_subscription_credential_exists scrubs the provider key vars before asserting the auto rung is unavailable, so the fixture rather than the developer's environment decides the result. The list was scoped to "vars the auto rung counts", and when OpenRouter joined that ladder in #1303 the list did not follow. The effect was a test that failed deterministically on any machine exporting OPENROUTER_API_KEY while staying green in CI, which has no such key — so it read as a regression from whatever the developer had just changed. Track provider existence instead of ladder membership: a new provider now only has to be a provider to be scrubbed, whether or not it is in the ladder yet, and scrubbing a var the ladder ignores costs nothing. Also picks up GROK_API_KEY / XAI_API_KEY, which were missing for the same reason and would have bitten the day grok joined the ladder. --- crates/daemon/src/availability.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/daemon/src/availability.rs b/crates/daemon/src/availability.rs index 4c2ff46a..b33abf29 100644 --- a/crates/daemon/src/availability.rs +++ b/crates/daemon/src/availability.rs @@ -886,9 +886,15 @@ mod tests { // `CODEX_HOME` could still interleave with this one's read. Take the // crate-wide guard every env-mutating test uses. let _lock = crate::router::oauth::test_env_guard(); - // Every direct-API-key var the auto rung counts. A var missing from - // this list makes the test pass or fail on the developer's own - // exported keys rather than on the fixture. + // Every provider key var this module can consult — deliberately wider + // than the auto rung's own ladder. Scoping it to "vars the auto rung + // counts" is what let this list rot: OpenRouter joined the ladder and + // the list did not, so on any machine exporting OPENROUTER_API_KEY the + // fixture was overruled by the developer's own key and the test failed + // locally while staying green in CI. Tracking provider existence + // instead means a new provider only has to be a provider to be + // scrubbed, whether or not it is in the ladder yet. Scrubbing a var the + // ladder ignores costs nothing. let key_vars = [ "ANTHROPIC_API_KEY", "OPENAI_API_KEY", @@ -896,7 +902,10 @@ mod tests { "GOOGLE_API_KEY", "META_API_KEY", "MODEL_API_KEY", + "GROK_API_KEY", + "XAI_API_KEY", "DEEPSEEK_API_KEY", + "OPENROUTER_API_KEY", ]; let saved_keys: Vec> = key_vars.iter().map(|v| std::env::var(v).ok()).collect();