{"record":{"id":"12bb94efb0de2994","repo":"HKUDS/nanobot","slug":"signing-key-not-found-for-kid-kid","errorCode":null,"errorMessage":"signing key not found for kid={kid}","messagePattern":"signing key not found for kid=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"nanobot/channels/msteams/runtime.py","lineNumber":493,"sourceCode":"            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        )\n\n        claim_service_url = str(\n            claims.get(\"serviceurl\") or claims.get(\"serviceUrl\") or \"\",\n        ).strip()\n        activity_service_url = str(activity.get(\"serviceUrl\") or \"\").strip()\n        if claim_service_url and activity_service_url and claim_service_url != activity_service_url:","sourceCodeStart":475,"sourceCodeEnd":511,"githubUrl":"https://github.com/HKUDS/nanobot/blob/42f37dc4c0e409eac7818a82d165c5f2757bc075/nanobot/channels/msteams/runtime.py#L475-L511","documentation":"Validation failure in _validate_inbound_auth: the token header's kid does not match any key in the fetched Bot Framework JWKS, so the token was not signed by a recognized Bot Framework signing key (possibly stale JWKS cache or a forged token).","triggerScenarios":"Thrown at nanobot/channels/msteams/runtime.py:493 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wait for the cached JWKS to expire (1h TTL) or restart the gateway to force a refetch if Bot Framework rotated its signing keys","Verify outbound HTTPS access to login.botframework.com OpenID/JWKS endpoints","Reject the request with 401; an unknown kid on a fresh JWKS indicates a forged token"],"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"}