{"record":{"id":"46f811bbee067f26","repo":"spring-projects/spring-security","slug":"an-error-occurred-reading-the-openid-client-regist","errorCode":null,"errorMessage":"An error occurred reading the OpenID Client Registration: ${ex.getMessage()}","messagePattern":"An error occurred reading the OpenID Client Registration: (.+?)","errorType":"http","errorClass":"HttpMessageNotReadableException","httpStatus":400,"severity":"error","filePath":"oauth2/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/oidc/http/converter/OidcClientRegistrationHttpMessageConverter.java","lineNumber":93,"sourceCode":"\t\tthis.jsonMessageConverter = converter;\n\t}\n\n\t@Override\n\tprotected boolean supports(Class<?> clazz) {\n\t\treturn OidcClientRegistration.class.isAssignableFrom(clazz);\n\t}\n\n\t@Override\n\t@SuppressWarnings(\"unchecked\")\n\tprotected OidcClientRegistration readInternal(Class<? extends OidcClientRegistration> clazz,\n\t\t\tHttpInputMessage inputMessage) throws HttpMessageNotReadableException {\n\t\ttry {\n\t\t\tMap<String, Object> clientRegistrationParameters = (Map<String, Object>) this.jsonMessageConverter\n\t\t\t\t.read(STRING_OBJECT_MAP.getType(), null, inputMessage);\n\t\t\treturn this.clientRegistrationConverter.convert(clientRegistrationParameters);\n\t\t}\n\t\tcatch (Exception ex) {\n\t\t\tthrow new HttpMessageNotReadableException(\n\t\t\t\t\t\"An error occurred reading the OpenID Client Registration: \" + ex.getMessage(), ex, inputMessage);\n\t\t}\n\t}\n\n\t@Override\n\tprotected void writeInternal(OidcClientRegistration clientRegistration, HttpOutputMessage outputMessage)\n\t\t\tthrows HttpMessageNotWritableException {\n\t\ttry {\n\t\t\tMap<String, Object> clientRegistrationParameters = this.clientRegistrationParametersConverter\n\t\t\t\t.convert(clientRegistration);\n\t\t\tthis.jsonMessageConverter.write(clientRegistrationParameters, STRING_OBJECT_MAP.getType(),\n\t\t\t\t\tMediaType.APPLICATION_JSON, outputMessage);\n\t\t}\n\t\tcatch (Exception ex) {\n\t\t\tthrow new HttpMessageNotWritableException(\n\t\t\t\t\t\"An error occurred writing the OpenID Client Registration: \" + ex.getMessage(), ex);\n\t\t}\n\t}","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/spring-projects/spring-security/blob/96852e8860138a482cb13d1479573f24ff6443c6/oauth2/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/oidc/http/converter/OidcClientRegistrationHttpMessageConverter.java#L75-L111","documentation":"OidcClientRegistrationHttpMessageConverter.readInternal deserializes an HTTP request body into an OidcClientRegistration. Any exception raised while reading the JSON body or converting the parameter map (via the configured Converter<Map<String,Object>, OidcClientRegistration>) is wrapped into an HttpMessageNotReadableException with the message \"An error occurred reading the OpenID Client Registration: <cause message>\". This signals a malformed or semantically invalid client registration payload.","triggerScenarios":"POSTing a client registration to the clientRegistrationEndpoint (or any endpoint using this converter) with a body that is not parseable JSON, not a JSON object, or that fails OidcClientRegistration validation — e.g. missing redirect_uris, invalid token_endpoint_auth_method value, or a field of the wrong JSON type.","commonSituations":"Sending form-encoded instead of JSON content-type; a typo like \"redirect_uri\" instead of \"redirect_uris\"; passing an array where an object is expected; invalid enum strings such as grant_type values; non-UTF8 bodies; ProGuard/serialization issues in test clients.","solutions":["Inspect the nested cause message to see the exact parse/convert failure and fix the request body accordingly.","Ensure the request uses Content-Type: application/json and the body is a JSON object matching the OIDC Dynamic Client Registration schema.","Validate required fields (client_name, redirect_uris for certain grant types, token_endpoint_auth_method) and allowed enum values before sending.","If you need custom fields, register a custom Converter<Map<String,Object>, OidcClientRegistration> that accepts them instead of relying on the default."],"exampleFix":"// before\nPOST /oauth2/register\nContent-Type: application/x-www-form-urlencoded\ngrant_type=client_credentials\n\n// after\nPOST /oauth2/register\nContent-Type: application/json\n{\n  \"client_name\": \"my-client\",\n  \"grant_types\": [\"client_credentials\"],\n  \"token_endpoint_auth_method\": \"client_secret_basic\",\n  \"scope\": \"openid\"\n}","handlingStrategy":"validation","validationCode":"boolean isValidRegistrationPayload(Map<String, Object> body) {\n    return body != null\n        && body.get(\"redirect_uris\") instanceof List\n        && body.get(\"grant_types\") instanceof List\n        && body.get(\"token_endpoint_auth_method\") instanceof String;\n}","typeGuard":"boolean isClientRegistrationBody(Object body) {\n    return body instanceof Map<?, ?> m\n        && m.get(\"client_name\") instanceof String\n        && m.get(\"redirect_uris\") instanceof List<?>;\n}","tryCatchPattern":"try {\n    OidcClientRegistration reg = converter.read(OidcClientRegistration.class, inputMessage);\n} catch (HttpMessageNotReadableException ex) {\n    log.warn(\"Bad client registration payload: {}\", ex.getCause() != null ? ex.getCause().getMessage() : ex.getMessage());\n    response.sendError(HttpStatus.BAD_REQUEST.value());\n}","preventionTips":["Send Content-Type: application/json with an OIDC Dynamic Client Registration compliant object.","Validate the payload against the OIDC registration metadata schema before POSTing.","Check the wrapped cause message for the precise field-level failure."],"tags":["http","json","deserialization","oidc","client-registration"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"96852e8860138a482cb13d1479573f24ff6443c6","analyzedAt":"2026-09-10T23:25:23.477Z","contentChangedAt":"2026-09-10T23:25:23.477Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}