{"record":{"id":"7a010e56c880f61b","repo":"quarkusio/quarkus","slug":"media-type-s-value-must-be-a-float-s","errorCode":null,"errorMessage":"Media type %s value must be a float: %s","messagePattern":"Media type (.+?) value must be a float: (.+?)","errorType":"http","errorClass":"WebApplicationException","httpStatus":400,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/util/MediaTypeHelper.java","lineNumber":47,"sourceCode":"\n    public static String toString(MediaType mediaType) {\n        return MediaTypeHeaderDelegate.INSTANCE.toString(mediaType);\n    }\n\n    private static float getQTypeWithParamInfo(MediaType type, String parameterName) {\n        if (type.getParameters() != null) {\n            String val = type.getParameters().get(parameterName);\n            try {\n                if (val != null) {\n                    float rtn = Float.parseFloat(val);\n                    if (rtn > 1.0F)\n                        throw new WebApplicationException(\n                                String.format(\"Media type %s greater than 1: %s\", parameterName, type),\n                                Response.Status.BAD_REQUEST);\n                    return rtn;\n                }\n            } catch (NumberFormatException e) {\n                throw new WebApplicationException(\n                        String.format(\"Media type %s value must be a float: %s\", parameterName, type),\n                        Response.Status.BAD_REQUEST);\n            }\n        }\n        return 2.0f;\n    }\n\n    public static float getQWithParamInfo(MediaType type) {\n        return getQTypeWithParamInfo(type, \"q\");\n    }\n\n    /**\n     * subtypes like application/*+xml\n     *\n     * @param subtype subtype\n     * @return true if subtype is composite\n     */\n    public static boolean isCompositeWildcardSubtype(String subtype) {","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/util/MediaTypeHelper.java#L29-L65","documentation":"MediaTypeHelper.getQTypeWithParamInfo attempts Float.parseFloat on the media type's q-type parameter; if the value is not a valid float it converts the NumberFormatException into a WebApplicationException with HTTP 400 BAD_REQUEST. This enforces that quality parameters are decimal numbers per HTTP specification.","triggerScenarios":"Sending a header like 'application/xml;q=high', 'text/plain;q=', or 'application/json;q=0,9' (comma decimal separator) during content negotiation via getQWithParamInfo.","commonSituations":"Locale-mistaken decimal commas (0,9 vs 0.9); symbolic weights ('q=high', 'q=normal'); truncated or corrupted headers from proxies; template placeholders left unrendered (q=${weight}).","solutions":["Fix the q parameter to a plain decimal using a dot, e.g. q=0.9","Remove the malformed parameter entirely if quality is irrelevant","If building headers programmatically, format floats with Locale.ROOT so a comma decimal separator is never emitted"],"exampleFix":"// before\nString q = String.format(\"%.1f\", weight); // may yield '0,9' in some locales\nbuilder.header(\"Accept\", \"application/json;q=\" + q);\n// after\nString q = String.format(Locale.ROOT, \"%.1f\", weight);\nbuilder.header(\"Accept\", \"application/json;q=\" + q);","handlingStrategy":"validation","validationCode":"Matcher m = java.util.regex.Pattern.compile(\";\\\\s*q\\\\s*=\\\\s*([^\"]+)\").matcher(mediaType);\nif (m.find()) Float.parseFloat(m.group(1).trim().replace(',', '.')); // throws early if invalid","typeGuard":null,"tryCatchPattern":"try { /* negotiation call */ } catch (WebApplicationException e) { if (e.getResponse().getStatus() == 400) { /* strip q param and retry */ } else throw e; }","preventionTips":["Format q floats with Locale.ROOT to avoid decimal commas","Only emit numeric q values from configuration, never free-text","Validate Accept headers in integration tests","Sanitize headers passing through proxies"],"tags":["http","media-type","content-negotiation","number-format"],"backgroundTag":"invalid-q-value","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"}