quarkusio/quarkus · warning · BadRequestException

Empty Field in header:

Error message

Empty Field in header: 

What it means

After stripping the quality parameter, getStringQualityValues() requires a non-empty media/language/charset token. If trimming leaves an empty string (e.g. a stray comma or a lone q parameter), this BadRequestException is thrown naming the offending header.

Source

Thrown at independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/request/AcceptHeaders.java:64

            if (qualityIndex >= 0) {
                String parameter = content.substring(qualityIndex + 1);
                content = content.substring(0, qualityIndex);

                int equalsIndex = parameter.indexOf('=');
                if (equalsIndex < 0) {
                    throw new BadRequestException("Malformed parameter: " + parameter);
                }
                String name = parameter.substring(0, equalsIndex).trim();
                if (!"q".equals(name)) {
                    throw new BadRequestException("Unsupported parameter: " + parameter);
                }
                String value = parameter.substring(equalsIndex + 1).trim();
                qualityValue = QualityValue.valueOf(value);
            }

            content = content.trim();
            if (content.length() == 0) {
                throw new BadRequestException("Empty Field in header: " + header);
            }
            if (content.equals("*")) {
                result.put(null, qualityValue);
            } else {
                result.put(content, qualityValue);
            }

            if (endIndex < 0) {
                break;
            }
            offset = endIndex + 1;
        }

        return result;
    }

    /**
     * Gets the locales from a comma-separated list.

View on GitHub (pinned to e1c734241f)

Solutions

  1. Fix the header so every comma-separated item contains a non-empty value
  2. Remove trailing/leading commas from programmatically joined header values
  3. Log and inspect the raw incoming header to find which client sends the malformed value

Example fix

// before
String langs = String.join(",", list) + ","; // trailing comma
// after
String langs = String.join(",", list);
Defensive patterns

Strategy: validation

Validate before calling

boolean noEmptyItems(String header) {
    if (header == null) return false;
    for (String item : header.split(",")) {
        String base = item.split(";")[0].trim();
        if (base.isEmpty()) return false;
    }
    return true;
}

Type guard

boolean isAcceptHeaderWellFormed(String header) {
    return header != null && !header.startsWith(",") && !header.endsWith(",")
        && !header.contains(",,");
}

Try / catch

try {
    result = AcceptHeaders.getStringQualityValues(header);
} catch (BadRequestException e) {
    result = Collections.emptyMap(); // treat as no preference
}

Prevention

When it happens

Trigger: Header values like 'Accept-Language: q=1.0', 'en,,fr', or 'Accept-Charset: ,' where an item is empty after trimming.

Common situations: String concatenation bugs building headers programmatically; trailing commas from joined lists; header values emptied by other filters.

Related errors


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