HKUDS/nanobot · error · RuntimeError
MSTeams HTTP client not initialized
Error message
MSTeams HTTP client not initialized
What it means
Lifecycle guard in MSTeamsChannel.send: self._http is None because stop() closed the HTTP client or the channel was never started, so an outbound message cannot be posted to the Teams conversations API. The message is rejected with RuntimeError instead of silently dropped.
Solutions
- Ensure the channel is started before messages are dispatched
- Restart the channel and requeue the message
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at nanobot/channels/msteams/runtime.py:254 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of HKUDS/nanobot@42f37dc4c0 (2026-08-26).
Data as JSON: /api/errors/38c200b5bb616a66.
Report an issue: GitHub.
Appendix: source
Thrown at nanobot/channels/msteams/runtime.py:254
async def stop(self) -> None:
"""Stop the channel."""
self._running = False
if self._server:
self._server.shutdown()
self._server.server_close()
self._server = None
if self._server_thread and self._server_thread.is_alive():
self._server_thread.join(timeout=2)
self._server_thread = None
if self._http:
await self._http.aclose()
self._http = None
async def send(self, msg: OutboundMessage) -> None:
"""Send a plain text reply into an existing Teams conversation."""
if not self._http:
raise RuntimeError("MSTeams HTTP client not initialized")
ref = self._conversation_refs.get(str(msg.chat_id))
if not ref:
raise RuntimeError(f"MSTeams conversation ref not found for chat_id={msg.chat_id}")
if not self._is_trusted_service_url(ref.service_url):
raise RuntimeError(
f"MSTeams conversation ref has untrusted service_url for chat_id={msg.chat_id}"
)
token = await self._get_access_token()
base_url = f"{ref.service_url.rstrip('/')}/v3/conversations/{ref.conversation_id}/activities"
use_thread_reply = self.config.reply_in_thread and bool(ref.activity_id)
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json",
}
payload = {View on GitHub (pinned to 42f37dc4c0)