{"record":{"id":"046f5b07253cc2dc","repo":"HKUDS/nanobot","slug":"dingtalk-access-token-unavailable","errorCode":null,"errorMessage":"DingTalk access token unavailable","messagePattern":"DingTalk access token unavailable","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"nanobot/channels/dingtalk/runtime.py","lineNumber":759,"sourceCode":"                \"sampleImageMsg\",\n                {\"photoURL\": media_id},\n            )\n            if ok:\n                return True\n            self.logger.warning(\"image media_id send failed, falling back to file: {}\", media_ref)\n\n        return await self._send_batch_message(\n            token,\n            chat_id,\n            \"sampleFile\",\n            {\"mediaId\": media_id, \"fileName\": filename, \"fileType\": file_type},\n        )\n\n    async def send(self, msg: OutboundMessage) -> None:\n        \"\"\"Send a message through DingTalk.\"\"\"\n        token = await self._get_access_token()\n        if not token:\n            raise RuntimeError(\"DingTalk access token unavailable\")\n\n        content = msg.content.strip() if msg.content else \"\"\n        if content:\n            # In group chats, prefix the reply with a markdown header naming the\n            # sender so the addressed user can spot the reply. Visual only —\n            # DingTalk's markdown robot messages do not push real @ notifications.\n            sender_name = msg.metadata.get(\"sender_name\") if msg.metadata else None\n            safe_sender_name = (\n                _escape_markdown_sender_name(sender_name)\n                if isinstance(sender_name, str)\n                else \"\"\n            )\n            if msg.chat_id.startswith(\"group:\") and safe_sender_name:\n                content = f\"# @{safe_sender_name}\\n\\n{content}\"\n            if not await self._send_markdown_text(token, msg.chat_id, content):\n                raise RuntimeError(\"DingTalk text message was not delivered\")\n\n        for media_ref in msg.media or []:","sourceCodeStart":741,"sourceCodeEnd":777,"githubUrl":"https://github.com/HKUDS/nanobot/blob/42f37dc4c0e409eac7818a82d165c5f2757bc075/nanobot/channels/dingtalk/runtime.py#L741-L777","documentation":"Error \"DingTalk access token unavailable\" thrown in HKUDS/nanobot.","triggerScenarios":"Thrown at nanobot/channels/dingtalk/runtime.py:759 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"42f37dc4c0e409eac7818a82d165c5f2757bc075","analyzedAt":"2026-08-26T00:18:52.276Z","schemaVersion":2},"datasetVersion":"2026-08-26T04:18:47.238Z"}