From fd4b4e072345fcc3a5356737dec0f8ff3643d9ea Mon Sep 17 00:00:00 2001 From: Hongming Wang Date: Sat, 2 May 2026 21:56:40 -0700 Subject: [PATCH] test: pin null-required_env tolerance + drop unused MINIMAX env clear MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two self-review nits on the prior commit: - Add test_per_model_required_env_null_treated_as_empty_no_auth — pins parser tolerance for YAML 'required_env:' (deserializes to None). The 'or []' fallback handles it, but the behavior wasn't asserted, and a template author who writes 'required_env:' with no value (common YAML mistake) needs the no-auth path, not a confusing TypeError. - Drop the MINIMAX_API_KEY delenv from the explicit-empty test — there's no MINIMAX in any required_env list of that scenario, so the cleanup was dead noise. 78/78 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) --- workspace/tests/test_preflight.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/workspace/tests/test_preflight.py b/workspace/tests/test_preflight.py index 71761ab9..febf536a 100644 --- a/workspace/tests/test_preflight.py +++ b/workspace/tests/test_preflight.py @@ -428,7 +428,6 @@ def test_per_model_explicit_empty_required_env_means_no_auth(tmp_path, monkeypat without lying in the per-model list. Distinguished from the no-key case via `"required_env" in entry` (key presence, not truthiness).""" monkeypatch.delenv("CLAUDE_CODE_OAUTH_TOKEN", raising=False) - monkeypatch.delenv("MINIMAX_API_KEY", raising=False) config = make_config( runtime="claude-code", @@ -450,6 +449,31 @@ def test_per_model_explicit_empty_required_env_means_no_auth(tmp_path, monkeypat assert not any(issue.title == "Required env" for issue in report.failures) +def test_per_model_required_env_null_treated_as_empty_no_auth(tmp_path, monkeypatch): + """YAML `required_env: null` deserializes to None — the parser falls + through to `entry.get("required_env") or []`, so null behaves the + same as explicit `[]` (zero-auth). Pins the parser tolerance — + template authors who write `required_env:` without a value (common + YAML mistake) get the no-auth path, not a confusing TypeError.""" + monkeypatch.delenv("CLAUDE_CODE_OAUTH_TOKEN", raising=False) + + config = make_config( + runtime="claude-code", + runtime_config=RuntimeConfig( + model="local-llama", + required_env=["CLAUDE_CODE_OAUTH_TOKEN"], + models=[ + {"id": "local-llama", "required_env": None}, # null in YAML + ], + ), + ) + + report = run_preflight(config, str(tmp_path)) + + assert report.ok is True + assert not any(issue.title == "Required env" for issue in report.failures) + + # ---------- Legacy auth_token_file backward compat ----------