Skip to content

fix(tests/gateway): stabilize xai env resolver + harden PATH probe against stat errors (salvage #26565)#27562

Merged
teknium1 merged 2 commits into
mainfrom
hermes/salvage-tier2
May 17, 2026
Merged

fix(tests/gateway): stabilize xai env resolver + harden PATH probe against stat errors (salvage #26565)#27562
teknium1 merged 2 commits into
mainfrom
hermes/salvage-tier2

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

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 import

Module-level from hermes_cli.config import get_env_value as _hermes_get_env_value was captured at import time, so test monkeypatches on hermes_cli.config.get_env_value were 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 in test_transcription_dotenv_fallback.py.

tests/run_agent/test_provider_parity.py — explicit model on nous helper

Three tests overrode agent.model after _make_agent() returned. With the helper's nous→gpt-5 default already in place, the explicit override is now passed via the model= 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() called path.is_dir() on four candidate directories. If any of those raised PermissionError (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 catches OSError. 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 on agent.auxiliary_client that expects gemini-3-flash-preview but main returns gemini-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.

@teknium1 teknium1 merged commit bc7c608 into main May 17, 2026
16 of 17 checks passed
@teknium1 teknium1 deleted the hermes/salvage-tier2 branch May 17, 2026 18:55
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/salvage-tier2 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8705 on HEAD, 8705 on base (➖ 0)

🆕 New issues (1):

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.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery provider/xai xAI (Grok) labels May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists provider/xai xAI (Grok) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants