{"record":{"id":"2c3901bd55b3dc00","repo":"HKUDS/nanobot","slug":"missing-token-kid","errorCode":null,"errorMessage":"missing token kid","messagePattern":"missing token kid","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"nanobot/channels/msteams/runtime.py","lineNumber":487,"sourceCode":"            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(\n            token,\n            key=cast(Any, public_key),\n            algorithms=[\"RS256\"],\n            audience=self.config.app_id,\n            issuer=\"https://api.botframework.com\",\n            options={\n                \"require\": [\"exp\", \"nbf\", \"iss\", \"aud\"],\n            },\n        )","sourceCodeStart":469,"sourceCodeEnd":505,"githubUrl":"https://github.com/HKUDS/nanobot/blob/42f37dc4c0e409eac7818a82d165c5f2757bc075/nanobot/channels/msteams/runtime.py#L469-L505","documentation":"Validation failure in _validate_inbound_auth: the unverified JWT header contains no 'kid' (key id) claim, so the signing key cannot be located in the Bot Framework JWKS. The faulty input is the inbound token's JOSE header.","triggerScenarios":"Thrown at nanobot/channels/msteams/runtime.py:487 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the token is a genuine Bot Framework-issued RS256 JWT, not a hand-crafted or malformed one","Check that the header is not stripped/mangled by an intermediary before it reaches validation","Treat requests without a kid as unauthenticated and return 401"],"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"}