quarkusio/quarkus · error · WebApplicationException
Media type %s greater than 1: %s
Error message
Media type %s greater than 1: %s
What it means
MediaTypeHelper.getQTypeWithParamInfo parses a quality (q) or similar numeric parameter from a media type and enforces the HTTP semantics that q values must lie in [0,1]. When the parameter is greater than 1.0 it throws a WebApplicationException with HTTP 400 BAD_REQUEST, because such a media type is contractually invalid.
Source
Thrown at independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/util/MediaTypeHelper.java:41
public static final MediaTypeComparator QS_COMPARATOR = new MediaTypeComparator("qs");
private static final String MEDIA_TYPE_SUFFIX_DELIM = "+";
public static MediaType valueOf(String value) {
return MediaTypeHeaderDelegate.INSTANCE.fromString(value);
}
public static String toString(MediaType mediaType) {
return MediaTypeHeaderDelegate.INSTANCE.toString(mediaType);
}
private static float getQTypeWithParamInfo(MediaType type, String parameterName) {
if (type.getParameters() != null) {
String val = type.getParameters().get(parameterName);
try {
if (val != null) {
float rtn = Float.parseFloat(val);
if (rtn > 1.0F)
throw new WebApplicationException(
String.format("Media type %s greater than 1: %s", parameterName, type),
Response.Status.BAD_REQUEST);
return rtn;
}
} catch (NumberFormatException e) {
throw new WebApplicationException(
String.format("Media type %s value must be a float: %s", parameterName, type),
Response.Status.BAD_REQUEST);
}
}
return 2.0f;
}
public static float getQWithParamInfo(MediaType type) {
return getQTypeWithParamInfo(type, "q");
}
/**View on GitHub (pinned to e1c734241f)
Solutions
- Correct the q parameter in the client's Accept/Content-Type header to a value between 0.0 and 1.0 (e.g. q=1 instead of q=1.5)
- If weights came from a 0-100 scale, divide by 100 before setting the header
- On the server, optionally catch WebApplicationException and return a friendlier 400 message naming the offending media type
Example fix
// before Accept: application/json;q=1.5 // after Accept: application/json;q=1.0
Defensive patterns
Strategy: validation
Validate before calling
Matcher m = java.util.regex.Pattern.compile(";\\s*q\\s*=\\s*([0-9.]+)").matcher(mediaType);
if (m.find() && Float.parseFloat(m.group(1)) > 1.0f) throw new IllegalArgumentException("q must be <= 1.0"); Try / catch
try { /* negotiation call */ } catch (WebApplicationException e) { if (e.getResponse().getStatus() == 400) { /* fix/rewrite header, retry with default q */ } else throw e; } Prevention
- Clamp q values to [0,1] when generating Accept headers programmatically
- Never use percentage-scale weights in q parameters
- Add client-side tests for emitted Accept headers
- Document q semantics for teams writing custom clients
When it happens
Trigger: Sending an Accept or Content-Type header whose q (or qs) parameter exceeds 1, e.g. 'application/json;q=1.5' or 'text/html;q=2'. Invoked via getQWithParamInfo during content negotiation.
Common situations: Hand-written Accept headers with mistaken q values; clients copy-pasting percentage-style weights (e.g. 100 instead of 1.0); misconfigured HTTP clients or generated code emitting weights on a 0-100 scale.
Related errors
- Media type %s value must be a float: %s
- Media type was null
- Param was null
- q value cannot be greater than one: ${lang}
- media type weighted language q must be a float: ${lang}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/2223dec18f677af7.
Report an issue: GitHub.