{"record":{"id":"863a917ffed36df5","repo":"quarkusio/quarkus","slug":"empty-field-in-header","errorCode":null,"errorMessage":"Empty Field in header: ","messagePattern":"Empty Field in header: ","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"warning","filePath":"independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/request/AcceptHeaders.java","lineNumber":64,"sourceCode":"            if (qualityIndex >= 0) {\n                String parameter = content.substring(qualityIndex + 1);\n                content = content.substring(0, qualityIndex);\n\n                int equalsIndex = parameter.indexOf('=');\n                if (equalsIndex < 0) {\n                    throw new BadRequestException(\"Malformed parameter: \" + parameter);\n                }\n                String name = parameter.substring(0, equalsIndex).trim();\n                if (!\"q\".equals(name)) {\n                    throw new BadRequestException(\"Unsupported parameter: \" + parameter);\n                }\n                String value = parameter.substring(equalsIndex + 1).trim();\n                qualityValue = QualityValue.valueOf(value);\n            }\n\n            content = content.trim();\n            if (content.length() == 0) {\n                throw new BadRequestException(\"Empty Field in header: \" + header);\n            }\n            if (content.equals(\"*\")) {\n                result.put(null, qualityValue);\n            } else {\n                result.put(content, qualityValue);\n            }\n\n            if (endIndex < 0) {\n                break;\n            }\n            offset = endIndex + 1;\n        }\n\n        return result;\n    }\n\n    /**\n     * Gets the locales from a comma-separated list.","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/request/AcceptHeaders.java#L46-L82","documentation":"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.","triggerScenarios":"Header values like 'Accept-Language: q=1.0', 'en,,fr', or 'Accept-Charset: ,' where an item is empty after trimming.","commonSituations":"String concatenation bugs building headers programmatically; trailing commas from joined lists; header values emptied by other filters.","solutions":["Fix the header so every comma-separated item contains a non-empty value","Remove trailing/leading commas from programmatically joined header values","Log and inspect the raw incoming header to find which client sends the malformed value"],"exampleFix":"// before\nString langs = String.join(\",\", list) + \",\"; // trailing comma\n// after\nString langs = String.join(\",\", list);","handlingStrategy":"validation","validationCode":"boolean noEmptyItems(String header) {\n    if (header == null) return false;\n    for (String item : header.split(\",\")) {\n        String base = item.split(\";\")[0].trim();\n        if (base.isEmpty()) return false;\n    }\n    return true;\n}","typeGuard":"boolean isAcceptHeaderWellFormed(String header) {\n    return header != null && !header.startsWith(\",\") && !header.endsWith(\",\")\n        && !header.contains(\",,\");\n}","tryCatchPattern":"try {\n    result = AcceptHeaders.getStringQualityValues(header);\n} catch (BadRequestException e) {\n    result = Collections.emptyMap(); // treat as no preference\n}","preventionTips":["Join header item lists with String.join(\",\", ...) instead of manual concatenation","Never append a trailing comma to header values","Unit-test header-building code with edge cases (empty lists, single items)"],"tags":["http","header-parsing","bad-request"],"backgroundTag":"malformed-http-header","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"}