{"record":{"id":"09e445e98b620900","repo":"quarkusio/quarkus","slug":"the-content-type-header-value-did-not-correspond-t-09e445","errorCode":null,"errorMessage":"The content-type header value did not correspond to a valid media type","messagePattern":"The content-type header value did not correspond to a valid media type","errorType":"http","errorClass":"NotSupportedException","httpStatus":415,"severity":"error","filePath":"independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/MediaTypeMapper.java","lineNumber":115,"sourceCode":"        }\n\n        if (selectedResource == null) {\n            throw new WebApplicationException(Response.status(Response.Status.NOT_ACCEPTABLE).build());\n        }\n        requestContext.restart(selectedResource);\n    }\n\n    private List<MediaType> contentTypeFromRequest(ResteasyReactiveRequestContext requestContext) {\n        List<String> contentTypeList = requestContext.getHttpHeaders().getRequestHeader(HttpHeaders.CONTENT_TYPE);\n        if (contentTypeList.isEmpty()) {\n            return Collections.singletonList(MediaType.WILDCARD_TYPE);\n        }\n        List<MediaType> result = new ArrayList<>(contentTypeList.size());\n        for (String s : contentTypeList) {\n            try {\n                result.add(MediaTypeHelper.valueOf(s));\n            } catch (IllegalArgumentException e) {\n                throw new NotSupportedException(\"The content-type header value did not correspond to a valid media type\");\n            }\n        }\n        return result;\n    }\n\n    public MediaType selectMediaType(ResteasyReactiveRequestContext requestContext, Holder holder) {\n        MediaType selected = null;\n        List<String> accepts = requestContext.getHttpHeaders().getRequestHeader(HttpHeaders.ACCEPT);\n        if (!accepts.isEmpty()) {\n            boolean sawParseableAccept = false;\n            for (String accept : accepts) {\n                // MediaTypeHelper.parseHeader skips unparseable tokens; an empty result means the header was malformed\n                if (!MediaTypeHelper.parseHeader(accept).isEmpty()) {\n                    sawParseableAccept = true;\n                }\n                Map.Entry<MediaType, MediaType> entry = holder.serverMediaType\n                        .negotiateProduces(accept, null);\n                if (entry.getValue() != null) {","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/MediaTypeMapper.java#L97-L133","documentation":"Thrown from MediaTypeMapper.contentTypeFromRequest (called by consumes) when one of the request's Content-Type header values cannot be parsed by MediaTypeHelper.valueOf; the IllegalArgumentException is converted to NotSupportedException (HTTP 415). It indicates a syntactically invalid Content-Type header rather than a mere mismatch with @Consumes.","triggerScenarios":"The request carries Content-Type header value(s); contentTypeFromRequest loops over contentTypeList and MediaTypeHelper.valueOf(s) throws IllegalArgumentException for a value such as 'application' or 'json;' which is caught and rethrown as this NotSupportedException at line 115.","commonSituations":"Malformed headers from hand-written clients or scripts; duplicate/conflicting Content-Type headers where one is garbage; middleware injecting placeholder or empty content types.","solutions":["Fix the Content-Type header to a well-formed type/subtype value (e.g. application/json).","Remove duplicate Content-Type headers, keeping a single valid one.","Log the raw incoming headers server-side to identify which client or intermediary emits the malformed value."],"exampleFix":"// before\ncurl -X POST -H 'Content-Type: application/json;' -d '{}' http://localhost:8080/api\n// after\ncurl -X POST -H 'Content-Type: application/json' -d '{}' http://localhost:8080/api","handlingStrategy":"validation","validationCode":"try {\n    jakarta.ws.rs.core.MediaType.valueOf(contentType);\n} catch (IllegalArgumentException e) {\n    throw new IllegalStateException(\"Refusing to send invalid Content-Type: \" + contentType);\n}","typeGuard":null,"tryCatchPattern":"try {\n    return client.post(entity);\n} catch (NotSupportedException e) {\n    log.error(\"Invalid Content-Type header value sent\", e);\n    throw e;\n}","preventionTips":["Send exactly one Content-Type header per request.","Validate header strings with MediaType.valueOf before sending.","Avoid manual header string building; use client APIs."],"tags":["rest","http-415","content-type","malformed-header"],"backgroundTag":"malformed-content-type-header","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}