{"record":{"id":"38c200b5bb616a66","repo":"HKUDS/nanobot","slug":"msteams-http-client-not-initialized","errorCode":null,"errorMessage":"MSTeams HTTP client not initialized","messagePattern":"MSTeams HTTP client not initialized","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"nanobot/channels/msteams/runtime.py","lineNumber":254,"sourceCode":"\n    async def stop(self) -> None:\n        \"\"\"Stop the channel.\"\"\"\n        self._running = False\n        if self._server:\n            self._server.shutdown()\n            self._server.server_close()\n            self._server = None\n        if self._server_thread and self._server_thread.is_alive():\n            self._server_thread.join(timeout=2)\n        self._server_thread = None\n        if self._http:\n            await self._http.aclose()\n            self._http = None\n\n    async def send(self, msg: OutboundMessage) -> None:\n        \"\"\"Send a plain text reply into an existing Teams conversation.\"\"\"\n        if not self._http:\n            raise RuntimeError(\"MSTeams HTTP client not initialized\")\n\n        ref = self._conversation_refs.get(str(msg.chat_id))\n        if not ref:\n            raise RuntimeError(f\"MSTeams conversation ref not found for chat_id={msg.chat_id}\")\n\n        if not self._is_trusted_service_url(ref.service_url):\n            raise RuntimeError(\n                f\"MSTeams conversation ref has untrusted service_url for chat_id={msg.chat_id}\"\n            )\n\n        token = await self._get_access_token()\n        base_url = f\"{ref.service_url.rstrip('/')}/v3/conversations/{ref.conversation_id}/activities\"\n        use_thread_reply = self.config.reply_in_thread and bool(ref.activity_id)\n        headers = {\n            \"Authorization\": f\"Bearer {token}\",\n            \"Content-Type\": \"application/json\",\n        }\n        payload = {","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/HKUDS/nanobot/blob/42f37dc4c0e409eac7818a82d165c5f2757bc075/nanobot/channels/msteams/runtime.py#L236-L272","documentation":"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.","triggerScenarios":"Thrown at nanobot/channels/msteams/runtime.py:254 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the channel is started before messages are dispatched","Restart the channel and requeue the message"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"42f37dc4c0e409eac7818a82d165c5f2757bc075","analyzedAt":"2026-08-26T00:18:52.276Z","contentChangedAt":"2026-08-26T00:18:52.276Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}