fix(tts): tolerate missing hermes_cli.config in tts_tool import

Wrap the new top-level `from hermes_cli.config import get_env_value`
in try/except ImportError and fall back to a thin os.getenv shim, so
importing tools.tts_tool keeps working in environments where
hermes_cli.config is unavailable. This matches the existing tolerance
in `_load_tts_config()` (tools/tts_tool.py) and the same
import-fallback pattern in tools/tool_backend_helpers.py::fal_key_is_configured.

Also update the TestDotenvFallbackPerProvider docstring to accurately
describe the mocking strategy: per-provider tests patch
`tools.tts_tool.get_env_value` directly, while the regression-guard
tests cover the lower-level `hermes_cli.config.load_env` integration.

Addresses Copilot review on #17163.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
briandevans
2026-04-28 16:06:37 -07:00
committed by Teknium
parent 40d25e125b
commit 33967b4e52
2 changed files with 11 additions and 4 deletions

View File

@@ -34,9 +34,12 @@ def isolate_env(monkeypatch):
class TestDotenvFallbackPerProvider:
"""For each affected provider, when only ``~/.hermes/.env`` carries the
key (mocked via ``hermes_cli.config.load_env``), the provider must find
it. Before the fix, ``os.getenv`` returned ``None`` and the provider
raised ``ValueError("X_API_KEY not set")``.
key, the provider must find it. These per-provider tests model that
dotenv-backed lookup by mocking ``tools.tts_tool.get_env_value`` directly;
the separate regression-guard tests cover the lower-level
``hermes_cli.config.load_env`` integration. Before the fix, ``os.getenv``
returned ``None`` and the provider raised
``ValueError("X_API_KEY not set")``.
"""
def test_elevenlabs_reads_dotenv_key(self, tmp_path):