{"record":{"id":"6e1a3a82d1cd0462","repo":"quarkusio/quarkus","slug":"response-could-not-be-mapped-to-type-entitytyp","errorCode":null,"errorMessage":"Response could not be mapped to type \" + entityType + \" for response with media type \" + mediaType","messagePattern":"Response could not be mapped to type \" \\+ entityType \\+ \" for response with media type \" \\+ mediaType","errorType":"exception","errorClass":"ProcessingException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/ClientReaderInterceptorContextImpl.java","lineNumber":133,"sourceCode":"                    public MediaType mediaType() {\n                        return mediaType;\n                    }\n                };\n                List<String> contextMessages = new ArrayList<>(contextualizers.size());\n                for (var contextualizer : contextualizers) {\n                    String contextMessage = contextualizer.provideContextMessage(input);\n                    if (contextMessage != null) {\n                        contextMessages.add(contextMessage);\n                    }\n                }\n                if (!contextMessages.isEmpty()) {\n                    errorMessage.append(\". Hints: \");\n                    errorMessage.append(String.join(\",\", contextMessages));\n                }\n            }\n\n            // Spec says to throw this\n            throw new ProcessingException(errorMessage.toString());\n        } else {\n            return interceptors[index++].aroundReadFrom(this);\n        }\n    }\n\n    @Override\n    public InputStream getInputStream() {\n        return inputStream;\n    }\n\n    @Override\n    public void setInputStream(InputStream is) {\n        this.inputStream = is;\n    }\n\n    @Override\n    public MultivaluedMap<String, String> getHeaders() {\n        return headers;","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/ClientReaderInterceptorContextImpl.java#L115-L151","documentation":"After walking all ReaderInterceptors and MessageBodyReaders, no reader could convert the response body into the requested Java type. ClientReaderInterceptorContextImpl.proceed() builds an error message including the target entityType and the response's media type (plus any reader hints collected in contextMessages) and throws ProcessingException, per the JAX-RS spec.","triggerScenarios":"Calling response.readEntity(SomeType.class) where no registered MessageBodyReader supports SomeType for the response's Content-Type — e.g. reading a text/plain response as a POJO, or a JSON response into a type without a matching reader/Jackson ObjectMapper config.","commonSituations":"Server returns a different Content-Type than expected (error pages as text/html); missing @Consumes on the client interface method; missing JSON-B/Jackson dependency or @RegisterForReflection for the target class; custom reader interceptors skipping the terminal reader.","solutions":["Match the requested type to the response Content-Type, or register a MessageBodyReader that supports the pair","Add the missing serialization dependency (quarkus-rest-jackson / quarkus-rest-jaxb) or annotate the type for reflection (@RegisterForReflection)","Fix @Consumes / Accept headers on the client method so the negotiated media type matches an available reader","Read the full ProcessingException message — the appended Hints list names what the attempted readers reported; fix the root hint"],"exampleFix":"// before\nString body = res.readEntity(MyDto.class); // media type text/plain\n\n// after\nif (res.getMediaType().isCompatible(MediaType.APPLICATION_JSON_TYPE)) {\n    MyDto dto = res.readEntity(MyDto.class);\n} else {\n    String text = res.readEntity(String.class); // handle non-JSON body\n}","handlingStrategy":"try-catch","validationCode":"// check compatibility before reading\nMediaType mt = response.getMediaType();\nif (mt == null || !mt.isCompatible(MediaType.APPLICATION_JSON_TYPE)) {\n    String raw = response.readEntity(String.class); // inspect body first\n    throw new IllegalStateException(\"Unexpected content-type \" + mt + \": \" + raw);\n}","typeGuard":null,"tryCatchPattern":"try {\n    return response.readEntity(MyDto.class);\n} catch (ProcessingException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Response could not be mapped to type\")) {\n        // fall back to String and log the raw body + media type\n        String raw = response.readEntity(String.class);\n        throw new IllegalStateException(\"Cannot map \" + response.getMediaType() + \" body: \" + raw, e);\n    }\n    throw e;\n}","preventionTips":["Check response.getMediaType() before readEntity with a POJO type","Ensure Jackson/JSON-B (quarkus-rest-jackson etc.) is on the classpath","Set @Consumes/Accept headers so negotiated media types match available readers","Register POJOs with @RegisterForReflection for native-image deserialization"],"tags":["deserialization","rest-client","media-type","jax-rs"],"backgroundTag":"no-message-body-reader-found","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}