SonarSource/sonarqube · error · IllegalArgumentException
Invalid format:
Error message
Invalid format:
What it means
After decoding, parseComplianceStandardsFilter splits the string on '&' and each part on '='; each part must be exactly key=value. If any segment deviates (0 or >1 '='), it throws 'Invalid format: <decodedParam>' as an IllegalArgumentException.
Solutions
- Format the parameter as repeated key=value segments joined by '&', e.g. cwe=20,89&owaspTop10=a1
- Encode '=' inside values as %3D so split("=") still yields exactly two parts
- Trim stray '&' separators before sending
- Validate with a regex like ^[^=&]+=[^=&]+(&[^=&]+=[^=&]+)*$ client-side
Example fix
// before filter=cwe=20=89 // after filter=cwe=20,89
Defensive patterns
Strategy: validation
Validate before calling
function isValidComplianceFilter(decoded) {
return /^([^=&]+=[^=&]+)(&[^=&]+=[^=&]+)*$/.test(decoded);
} Try / catch
try {
await api.searchIssues({ complianceStandards: filter });
} catch (e) {
if (e.status === 400 && /Invalid format: /.test(e.message)) {
throw new Error(`Filter must be key=value pairs joined by '&': got '${filter}'`);
}
throw e;
} Prevention
- Build the filter programmatically: pairs.map(([k,v]) => `${k}=${v}`).join('&')
- Encode '=' and '&' occurring inside values (%3D, %26)
- Trim trailing separators before sending
- Validate with the regex above in client code
When it happens
Trigger: Supplying a filter like 'key' (no =), 'key=a=b' (extra =), or an empty/stray '&' segment in the compliance standards parameter.
Common situations: Hand-built query strings not escaped, using ';' instead of '&' as separator, trailing '&' from concatenation, values containing unencoded '='.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Can't URI decode
- Invalid impact format
- a JVM option can't be empty and must start with '-'. The…
- a JVM option can't overwrite mandatory JVM options. The…
- a JVM option can't overwrite mandatory JVM options.
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/9526ca4dbc08303f.
Report an issue: GitHub.
Appendix: source
Thrown at server/sonar-webserver-webapi/src/main/java/org/sonar/server/common/ParamParsingUtils.java:67
public static Map<ReportKey, Set<String>> parseComplianceStandardsFilter(@Nullable String param) {
if (param == null) {
return Map.of();
}
String decodedParam;
try {
decodedParam = URLDecoder.decode(param, StandardCharsets.UTF_8);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Can't URI decode: " + param, e);
}
Map<ReportKey, Set<String>> categoriesByStandard = new HashMap<>();
String[] parts = decodedParam.split("&");
for (String part : parts) {
String[] keyValue = part.split("=");
if (keyValue.length != 2) {
throw new IllegalArgumentException("Invalid format: " + decodedParam);
}
Set<String> values = Arrays.stream(keyValue[1].split(",")).filter(s -> !s.isBlank()).collect(Collectors.toSet());
categoriesByStandard.put(ReportKey.parse(keyValue[0]), values);
}
return categoriesByStandard;
}
}
View on GitHub (pinned to 184c821202)