{"record":{"id":"bf1fd25834ee2347","repo":"quarkusio/quarkus","slug":"q-value-cannot-be-greater-than-one-lang","errorCode":null,"errorMessage":"q value cannot be greater than one: ${lang}","messagePattern":"q value cannot be greater than one: (.+?)","errorType":"http","errorClass":"WebApplicationException","httpStatus":400,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/util/WeightedLanguage.java","lineNumber":89,"sourceCode":"            params = lang.substring(idx + 1).trim();\n            lang = lang.substring(0, idx);\n        }\n        HashMap<String, String> typeParams = new HashMap<String, String>();\n        if (params != null && !params.equals(\"\")) {\n            int start = 0;\n            while (start < params.length()) {\n                start = HeaderParameterParser.setParam(typeParams, params, start);\n            }\n        }\n        return new WeightedLanguage(lang, typeParams);\n    }\n\n    private static float getQWithParamInfo(WeightedLanguage lang, String val) {\n        try {\n            if (val != null) {\n                float rtn = Float.valueOf(val);\n                if (rtn > 1.0F)\n                    throw new WebApplicationException(\"q value cannot be greater than one: \" + (lang.toString()),\n                            Response.Status.BAD_REQUEST);\n                return rtn;\n            }\n        } catch (NumberFormatException e) {\n            throw new WebApplicationException(\"media type weighted language q must be a float: \" + (lang.toString()),\n                    Response.Status.BAD_REQUEST);\n        }\n        return 1.0f;\n    }\n\n    @Override\n    public boolean equals(Object obj) {\n        return super.equals(obj);\n    }\n\n    @Override\n    public int hashCode() {\n        return super.hashCode();","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/util/WeightedLanguage.java#L71-L107","documentation":"When parsing an Accept-Language style header, WeightedLanguage validates the q parameter. A q value greater than 1.0 is invalid per HTTP content negotiation, so a WebApplicationException with HTTP 400 Bad Request is thrown. The message includes the offending language string to identify the bad part of the header.","triggerScenarios":"Sending an Accept-Language header containing a language with q>1, e.g. \"en;q=1.5\" or \"fr;q=2\"; WeightedLanguage's constructor calls getQWithParamInfo which parses the q value and throws.","commonSituations":"Malformed client-generated Accept-Language headers; buggy HTTP clients or proxies that normalize q incorrectly; manually written headers in tests or curl commands with q=2 meant as priority.","solutions":["Fix the client to send q values in the valid range 0.0–1.0 (q=1 means highest)","Clamp q to 1.0 in a request filter/ContainerRequestFilter before RESTEasy Reactive parses the header","Strip the q parameter from offending languages in a header-rewriting proxy","Catch WebApplicationException in custom parsing code and default the language q to 1.0"],"exampleFix":"// before\nAccept-Language: en;q=1.5, fr\n// after\nAccept-Language: en;q=1.0, fr","handlingStrategy":"validation","validationCode":"static void validateAcceptLanguage(String header) {\n    for (String part : header.split(\",\")) {\n        int q = part.toLowerCase().indexOf(\"q=\");\n        if (q >= 0) {\n            float v = Float.parseFloat(part.substring(q + 2).trim());\n            if (v > 1.0f || v < 0.0f) throw new BadRequestException(\"q out of range: \" + part);\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    response = client.target(uri).request().header(\"Accept-Language\", lang).get();\n} catch (BadRequestException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"q value cannot be greater than one\")) {\n    // clamp and retry\n    lang = lang.replaceAll(\"q=[0-9.]+\", \"q=1.0\");\n    response = client.target(uri).request().header(\"Accept-Language\", lang).get();\n    } else throw e;\n}","preventionTips":["Always emit q values in [0.0, 1.0] when generating Accept-Language headers","Clamp or normalize q in an HTTP filter/proxy before hitting the server","Add client-side validation of generated negotiation headers in tests","Remember q=1 (default) means highest priority, never exceed it"],"tags":["http","content-negotiation","accept-language"],"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-12T22:17:10.623Z"}