{"record":{"id":"33de90cd662ca49a","repo":"BerriAI/litellm","slug":"error-parsing-response-e-check-server-logs-for","errorCode":null,"errorMessage":"Error parsing response: {e}. Check server logs for original response.","messagePattern":"Error parsing response: (.+?)\\. Check server logs for original response\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/auth/handle_jwt.py","lineNumber":661,"sourceCode":"        litellm_jwtauth: Final = getattr(self, \"litellm_jwtauth\", None)\n        if litellm_jwtauth is None:\n            return 600\n        return litellm_jwtauth.public_key_ttl\n\n    async def _get_public_key_from_jwks_url(self, jwks_url: str, kid: str | None) -> dict:\n        resolved_jwks_url: Final = await self._resolve_jwks_url(jwks_url)\n        cache_key: Final = f\"litellm_jwt_auth_keys_{resolved_jwks_url}\"\n\n        cached_keys: Final = await self.user_api_key_cache.async_get_cache(cache_key)\n\n        if cached_keys is None:\n            response: Final = await self.http_handler.get(resolved_jwks_url)\n\n            try:\n                response_json: Final = response.json()\n            except Exception as e:\n                verbose_proxy_logger.error(\"Error parsing response: %s. Original Response: %s\", e, response.text)\n                raise Exception(f\"Error parsing response: {e}. Check server logs for original response.\")\n\n            if \"keys\" in response_json:\n                keys: JWKKeyValue = response_json[\"keys\"]\n            else:\n                keys = response_json\n\n            await self.user_api_key_cache.async_set_cache(\n                key=cache_key,\n                value=keys,\n                ttl=self._get_public_key_cache_ttl(),\n            )\n        else:\n            keys = cached_keys\n\n        public_key: Final = self.parse_keys(keys=keys, kid=kid)\n        if public_key is not None:\n            return cast(dict, public_key)\n","sourceCodeStart":643,"sourceCodeEnd":679,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/auth/handle_jwt.py#L643-L679","documentation":"Raised while fetching JWKS keys in _get_public_key_from_jwks_url: the keys URL answered, but response.json() raised, so the body is not parseable JSON. The full original response text is logged (verbose_proxy_logger.error) but deliberately omitted from the exception; the message tells you to check server logs for it.","triggerScenarios":"The resolved JWKS URL (from jwks_uri or a directly configured JWT_PUBLIC_KEY_URL without the discovery substring) returns HTML or invalid JSON - for example an IdP login page, a WAF block page, or a 200-status error page.","commonSituations":"JWKS endpoint requires authentication and returns an HTML login form; wrong jwks_uri in a custom IdP; API gateway rewriting /certs to an HTML error page; checking only status codes (200) while the body is HTML.","solutions":["curl the exact JWKS URL from the proxy host and confirm the body is JSON containing keys or a bare JWK","Check the LiteLLM proxy logs for 'Error parsing response: ... Original Response: ...' to see the actual body that failed to parse","Make the JWKS endpoint publicly readable (standard OIDC practice) or fix the jwks_uri the discovery document advertises"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import httpx\n\nasync def jwks_url_serves_json(jwks_url: str) -> bool:\n    async with httpx.AsyncClient() as c:\n        r = await c.get(jwks_url)\n        try:\n            data = r.json()\n        except ValueError:\n            return False\n        return isinstance(data, (dict, list))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm JWKS endpoints are publicly readable (standard OIDC practice) - no auth walls","Check proxy logs for 'Original Response:' to see the exact non-JSON body when it fires"],"tags":["jwt","jwks","json","authentication","key-management"],"backgroundTag":"invalid-json-response","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}