Skip to content

The agent that grows with you

fix(google-chat): let ensure_deps_fn surface the lazy-install reason

teknium1afe06f21f45f
diff --git a/plugins/platforms/google_chat/adapter.py b/plugins/platforms/google_chat/adapter.py
index c73ddd3bd72..46e29dae826 100644
--- a/plugins/platforms/google_chat/adapter.py
+++ b/plugins/platforms/google_chat/adapter.py
@@ -195,15 +195,14 @@ def ensure_google_chat_deps() -> bool:
Routes through ``tools.lazy_deps`` so sealed hosted/Docker images write
``HERMES_LAZY_INSTALL_TARGET`` instead of the read-only venv. Resets the
failed-import cache so ``create_adapter()`` can load modules after install.
+ ``FeatureUnavailable`` propagates: the registry logs its ``reason`` (quarantine
+ 404, no writable target, network), which is exactly what a hosted operator needs.
"""
global _google_modules_loaded, GOOGLE_CHAT_AVAILABLE
if GOOGLE_CHAT_AVAILABLE:
return True
- try:
- from tools.lazy_deps import ensure as _lazy_ensure
- _lazy_ensure("platform.google_chat", prompt=False)
- except Exception:
- return False
+ from tools.lazy_deps import ensure as _lazy_ensure
+ _lazy_ensure("platform.google_chat", prompt=False)
_google_modules_loaded = False
return _load_google_modules()
diff --git a/tests/gateway/test_google_chat_oauth_dependencies.py b/tests/gateway/test_google_chat_oauth_dependencies.py
index 0d71a8118c3..81ac19b91a4 100644
--- a/tests/gateway/test_google_chat_oauth_dependencies.py
+++ b/tests/gateway/test_google_chat_oauth_dependencies.py
@@ -61,3 +61,19 @@ def test_installer_repairs_stale_transitives(monkeypatch):
assert oauth.install_deps() is True
assert calls == [("platform.google_chat", False)]
assert pip_calls == []
+
+
+def test_ensure_deps_surfaces_install_reason(monkeypatch):
+ """A blocked lazy install must reach the registry's log with its reason, not a bare False."""
+ from tools.lazy_deps import FeatureUnavailable
+ import pytest
+ from plugins.platforms.google_chat import adapter
+
+ monkeypatch.setattr(adapter, "GOOGLE_CHAT_AVAILABLE", False)
+
+ def blocked(feature, prompt=False):
+ raise FeatureUnavailable(feature, ("google-cloud-pubsub==2.39.0",), "lazy install target /x is not writable")
+
+ monkeypatch.setattr("tools.lazy_deps.ensure", blocked)
+ with pytest.raises(FeatureUnavailable, match="not writable"):
+ adapter.ensure_google_chat_deps()