fix(tests/gateway): stabilize xai env resolver + harden PATH probe against stat errors (salvage #26565)#27562
Merged
Merged
Conversation
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
invalid-assignment |
1 |
First entries
tests/tools/test_transcription_dotenv_fallback.py:69: [invalid-assignment] invalid-assignment: Object of type `ModuleType` is not assignable to `<module 'tools.xai_http'>`
✅ Fixed issues (1):
| Rule | Count |
|---|---|
invalid-assignment |
1 |
First entries
tools/xai_http.py:11: [invalid-assignment] invalid-assignment: Object of type `None` is not assignable to `def get_env_value(key: str) -> str | None`
Unchanged: 4586 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
3 tasks
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.
Summary
Salvage of #26565 — two related test/runtime stabilizations that w0lfgang88 flagged as the unblocker for several other PRs failing post-#25957.
Changes
tools/xai_http.py— defer hermes_cli.config importModule-level
from hermes_cli.config import get_env_value as _hermes_get_env_valuewas captured at import time, so test monkeypatches onhermes_cli.config.get_env_valuewere silently bypassed. Move the import inside the function so each call re-resolves and dotenv fallback tests can actually exercise the dotenv path. New regression test intest_transcription_dotenv_fallback.py.tests/run_agent/test_provider_parity.py— explicit model on nous helperThree tests overrode
agent.modelafter_make_agent()returned. With the helper's nous→gpt-5default already in place, the explicit override is now passed via themodel=kwarg (same end state, no double assignment). Equivalent behavior, cleaner test code.hermes_cli/gateway.py— handle stat-error on PATH probes_build_service_path_dirs()calledpath.is_dir()on four candidate directories. If any of those raisedPermissionError(e.g. EACCES on a stat in restricted root configs, common in containers and test fixtures), the whole gateway probe crashed. Wrap each call in_is_dir()that catchesOSError. Same effective semantics — if we can't stat it, treat it as absent. This is the substantive part of #26640 (which is now superseded — see below).Validation
scripts/run_tests.sh tests/run_agent/test_provider_parity.py tests/tools/test_transcription_dotenv_fallback.py tests/hermes_cli/test_gateway.py tests/hermes_cli/test_gateway_service.py -q→ 262/263 pass. Single failure (test_openrouter_always_wins) is a pre-existing change-detector test onagent.auxiliary_clientthat expectsgemini-3-flash-previewbut main returnsgemini-2.5-flash— completely unrelated to this PR.Original PR: #26565 — credit preserved via rebase-merge. Skipped the upstream merge commit from the source branch and cherry-picked the two substantive commits.