{"record":{"id":"00fdedfcfff39b3a","repo":"quarkusio/quarkus","slug":"request-could-not-be-mapped-to-type-generictype-00fded","errorCode":null,"errorMessage":"Request could not be mapped to type ${genericType != null ? genericType : entityType}","messagePattern":"Request could not be mapped to type (.+?)","errorType":"exception","errorClass":"ProcessingException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/RestResponseImpl.java","lineNumber":142,"sourceCode":"    }\n\n    public InputStream getEntityStream() {\n        return entityStream;\n    }\n\n    public void setEntityStream(InputStream entityStream) {\n        this.entityStream = entityStream;\n    }\n\n    protected <T> T readEntity(Class<T> entityType, Type genericType, Annotation[] annotations) {\n        // TODO: we probably need better state handling\n        if (entity != null && entityType.isInstance(entity)) {\n            // Note that this works if entityType is InputStream where we return it without closing it, as per spec\n            return (T) entity;\n        }\n        checkClosed();\n        // Spec says to throw this\n        throw new ProcessingException(\n                \"Request could not be mapped to type \" + (genericType != null ? genericType : entityType));\n    }\n\n    @Override\n    public <OtherT> OtherT readEntity(Class<OtherT> entityType) {\n        return readEntity(entityType, entityType, null);\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    @Override\n    public <OtherT> OtherT readEntity(GenericType<OtherT> entityType) {\n        return (OtherT) readEntity(entityType.getRawType(), entityType.getType(), null);\n    }\n\n    @Override\n    public <OtherT> OtherT readEntity(Class<OtherT> entityType, Annotation[] annotations) {\n        return readEntity(entityType, entityType, annotations);\n    }","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/RestResponseImpl.java#L124-L160","documentation":"RestResponseImpl.readEntity throws this ProcessingException when the response cannot produce an entity of the requested type. Per the JAX-RS spec, if no entity is present (or the existing entity is not an instance of the requested type) and no suitable MessageBodyReader can map the raw stream to the target type, the request 'could not be mapped'. The message shows the generic type or class that was requested.","triggerScenarios":"Calling readEntity(Foo.class) on a response that (a) was closed, (b) has no entity, or (c) whose entity stream cannot be converted to Foo because no MessageBodyReader is registered for that type/media-type combination.","commonSituations":"Reading a JSON response into a POJO when the REST client Reactive JSON-B/Jackson mapper is not on the classpath; calling readEntity twice without buffering; reading entity after close(); expecting an entity on a 204 No Content response.","solutions":["Verify a JSON binding provider (quarkus-rest-jackson or quarkus-rest-jsonb) is a dependency so a MessageBodyReader exists for your type","Check response.hasEntity() / status before calling readEntity; handle 204/empty bodies","Call bufferEntity() before reading if you need to read the entity more than once","Ensure readEntity is called with the correct type matching the actual response content-type"],"exampleFix":"// before\nFoo foo = response.readEntity(Foo.class); // ProcessingException if no reader\n// after\nif (response.getStatus() == 204 || !response.hasEntity()) {\n    return null;\n}\nFoo foo = response.bufferEntity().readEntity(Foo.class);","handlingStrategy":"validation","validationCode":"if (response == null || response.getStatusInfo().family == Family.CLIENT_ERROR || response.getStatusInfo().family == Family.SERVER_ERROR || !response.hasEntity()) {\n    return fallback();\n}","typeGuard":"boolean isReadable(RestResponse<?> r, Class<?> type) {\n    return r != null && !r.isClosed() && r.hasEntity() && r.getMediaType() != null;\n}","tryCatchPattern":"try {\n    return response.readEntity(Foo.class);\n} catch (ProcessingException e) {\n    log.error(\"Entity not mappable to Foo: \" + e.getMessage());\n    return fallback();\n}","preventionTips":["Always add a JSON binding extension (quarkus-rest-jackson/jsonb) when reading POJOs","Check status and hasEntity() before readEntity","Buffer the entity if multiple reads are needed","Match readEntity type to the actual response media type"],"tags":["jaxrs","rest-client","entity-mapping","processing-exception"],"backgroundTag":"response-entity-unreadable","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}