quarkusio/quarkus · error · WebApplicationException

q value cannot be greater than one: ${lang}

Error message

q value cannot be greater than one: ${lang}

What it means

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.

Source

Thrown at independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/util/WeightedLanguage.java:89

            params = lang.substring(idx + 1).trim();
            lang = lang.substring(0, idx);
        }
        HashMap<String, String> typeParams = new HashMap<String, String>();
        if (params != null && !params.equals("")) {
            int start = 0;
            while (start < params.length()) {
                start = HeaderParameterParser.setParam(typeParams, params, start);
            }
        }
        return new WeightedLanguage(lang, typeParams);
    }

    private static float getQWithParamInfo(WeightedLanguage lang, String val) {
        try {
            if (val != null) {
                float rtn = Float.valueOf(val);
                if (rtn > 1.0F)
                    throw new WebApplicationException("q value cannot be greater than one: " + (lang.toString()),
                            Response.Status.BAD_REQUEST);
                return rtn;
            }
        } catch (NumberFormatException e) {
            throw new WebApplicationException("media type weighted language q must be a float: " + (lang.toString()),
                    Response.Status.BAD_REQUEST);
        }
        return 1.0f;
    }

    @Override
    public boolean equals(Object obj) {
        return super.equals(obj);
    }

    @Override
    public int hashCode() {
        return super.hashCode();

View on GitHub (pinned to e1c734241f)

Solutions

  1. Fix the client to send q values in the valid range 0.0–1.0 (q=1 means highest)
  2. Clamp q to 1.0 in a request filter/ContainerRequestFilter before RESTEasy Reactive parses the header
  3. Strip the q parameter from offending languages in a header-rewriting proxy
  4. Catch WebApplicationException in custom parsing code and default the language q to 1.0

Example fix

// before
Accept-Language: en;q=1.5, fr
// after
Accept-Language: en;q=1.0, fr
Defensive patterns

Strategy: validation

Validate before calling

static void validateAcceptLanguage(String header) {
    for (String part : header.split(",")) {
        int q = part.toLowerCase().indexOf("q=");
        if (q >= 0) {
            float v = Float.parseFloat(part.substring(q + 2).trim());
            if (v > 1.0f || v < 0.0f) throw new BadRequestException("q out of range: " + part);
        }
    }
}

Try / catch

try {
    response = client.target(uri).request().header("Accept-Language", lang).get();
} catch (BadRequestException e) {
    if (e.getMessage() != null && e.getMessage().contains("q value cannot be greater than one")) {
    // clamp and retry
    lang = lang.replaceAll("q=[0-9.]+", "q=1.0");
    response = client.target(uri).request().header("Accept-Language", lang).get();
    } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/bf1fd25834ee2347. Report an issue: GitHub.