{"record":{"id":"f2b6ad5cfb001071","repo":"HKUDS/nanobot","slug":"missing-bearer-token","errorCode":null,"errorMessage":"missing bearer token","messagePattern":"missing bearer token","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"nanobot/channels/msteams/runtime.py","lineNumber":478,"sourceCode":"        return cleaned\n\n    def _format_reply_with_quote(self, quoted: str, reply: str) -> str:\n        \"\"\"Format a reply-with-context message for the model without Teams wrapper noise.\"\"\"\n        quoted = quoted.strip()\n        reply = reply.strip()\n        if quoted and reply:\n            return f\"User is replying to: {quoted}\\nUser reply: {reply}\"\n        if reply:\n            return reply\n        return quoted\n\n    async def _validate_inbound_auth(self, auth_header: str, activity: dict[str, Any]) -> None:\n        \"\"\"Validate inbound Bot Framework bearer token.\"\"\"\n        if not MSTEAMS_AVAILABLE:\n            raise RuntimeError(\"PyJWT not installed. Run: nanobot plugins enable msteams\")\n\n        if not auth_header.lower().startswith(\"bearer \"):\n            raise ValueError(\"missing bearer token\")\n\n        token = auth_header.split(\" \", 1)[1].strip()\n        if not token:\n            raise ValueError(\"empty bearer token\")\n\n        header = jwt.get_unverified_header(token)\n        kid = str(header.get(\"kid\") or \"\").strip()\n        if not kid:\n            raise ValueError(\"missing token kid\")\n\n        jwks = await self._get_botframework_jwks()\n        keys = cast(list[dict[str, Any]], jwks.get(\"keys\") or [])\n        jwk = next((key for key in keys if key.get(\"kid\") == kid), None)\n        if not jwk:\n            raise ValueError(f\"signing key not found for kid={kid}\")\n\n        public_key = RSAAlgorithm.from_jwk(json.dumps(jwk))\n        claims = jwt.decode(","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/HKUDS/nanobot/blob/42f37dc4c0e409eac7818a82d165c5f2757bc075/nanobot/channels/msteams/runtime.py#L460-L496","documentation":"Validation failure in _validate_inbound_auth: the Authorization header does not start with 'Bearer ' (case-insensitive), so no JWT can be extracted for Bot Framework token verification. The faulty input is the inbound HTTP Authorization header.","triggerScenarios":"Thrown at nanobot/channels/msteams/runtime.py:478 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the webhook consumer forwards the original Authorization header unchanged","Confirm requests originate from Azure Bot Service, which always sends a bearer token","Reject or 401 any caller that cannot present a token; do not bypass validation in development"],"exampleFix":null,"handlingStrategy":"validation","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"}