{"record":{"id":"3cd40513cbbbb382","repo":"alibaba/nacos","slug":"failed-to-parse-oidc-configuration","errorCode":null,"errorMessage":"Failed to parse OIDC configuration","messagePattern":"Failed to parse OIDC configuration","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"plugin-default-impl/nacos-oidc-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/oidc/config/OidcProviderMetadataProvider.java","lineNumber":116,"sourceCode":"            Map<String, Object> values = JsonUtils.toObj(response.body(), Map.class);\n            if (values == null) {\n                throw new IOException(\"OIDC discovery response is empty\");\n            }\n            OidcProviderMetadata result = new OidcProviderMetadata(\n                stringValue(values, OidcProtocolConstants.DISCOVERY_AUTHORIZATION_ENDPOINT),\n                stringValue(values, OidcProtocolConstants.DISCOVERY_TOKEN_ENDPOINT),\n                stringValue(values, OidcProtocolConstants.DISCOVERY_USERINFO_ENDPOINT),\n                stringValue(values, OidcProtocolConstants.DISCOVERY_END_SESSION_ENDPOINT),\n                stringValue(values, OidcProtocolConstants.DISCOVERY_JWKS_URI));\n            LOGGER.info(\"OIDC configuration discovered: jwksUri={}\", result.getJwksUri());\n            return result;\n        } catch (InterruptedException e) {\n            Thread.currentThread().interrupt();\n            throw new IOException(\"OIDC discovery interrupted\", e);\n        } catch (IOException e) {\n            throw e;\n        } catch (RuntimeException e) {\n            throw new IOException(\"Failed to parse OIDC configuration\", e);\n        }\n    }\n    \n    private String stringValue(Map<String, Object> values, String key) {\n        Object value = values.get(key);\n        return value == null ? null : value.toString();\n    }\n    \n    private String trimTrailingSlash(String value) {\n        int end = value.length();\n        while (end > 0 && value.charAt(end - 1) == '/') {\n            end--;\n        }\n        return value.substring(0, end);\n    }\n}\n","sourceCodeStart":98,"sourceCodeEnd":133,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/plugin-default-impl/nacos-oidc-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/oidc/config/OidcProviderMetadataProvider.java#L98-L133","documentation":"A catch-all wrapping any RuntimeException raised during discovery parsing — e.g. a JSON deserialization error from JsonUtils, a ClassCastException, or an NPE while reading fields. The original exception is attached as the cause.","triggerScenarios":"Discovery returned 200 and a non-null body, but the body is malformed JSON or has unexpected types, so JsonUtils.toObj throws a runtime exception while building the Map.","commonSituations":"Discovery endpoint returns HTML/text instead of JSON (e.g. an error page); JSON contains nested structures incompatible with Map<String,Object>; partial/garbled response from a proxy.","solutions":["Inspect the wrapped cause exception for the exact parse failure.","curl the discovery URL and verify the body is valid JSON with the OIDC endpoint fields.","Ensure no proxy/CDN injects HTML error pages with a 200 status.","Confirm issuer-uri points to the real OIDC discovery endpoint, not a web UI."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight: confirm the discovery body is valid JSON before trusting it\n// (parse the curl'd body with a JSON parser and assert it is an object with endpoint fields)","typeGuard":null,"tryCatchPattern":"try {\n    metadataProvider.getMetadata();\n} catch (IOException e) {\n    if (\"Failed to parse OIDC configuration\".equals(e.getMessage())) {\n        Throwable cause = e.getCause();\n        log.error(\"Discovery body unparseable: {}\", cause == null ? \"?\" : cause.toString());\n    }\n    throw e;\n}","preventionTips":["Validate the discovery document is well-formed JSON (not HTML/text).","Ensure no proxy injects HTML error pages with a 200 status.","Point issuer-uri at the real OIDC discovery endpoint."],"tags":["oidc","discovery","parsing","network"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}