{"record":{"id":"7b3c14d011093639","repo":"SonarSource/sonarqube","slug":"invalid-impact-format-impact","errorCode":null,"errorMessage":"Invalid impact format: ${impact}","messagePattern":"Invalid impact format: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"server/sonar-webserver-webapi/src/main/java/org/sonar/server/common/ParamParsingUtils.java","lineNumber":43,"sourceCode":"import java.util.HashMap;\nimport java.util.Map;\nimport java.util.Set;\nimport java.util.stream.Collectors;\nimport javax.annotation.Nullable;\nimport org.apache.commons.lang3.tuple.Pair;\nimport org.sonar.api.issue.impact.Severity;\nimport org.sonar.api.issue.impact.SoftwareQuality;\nimport org.sonarsource.compliancereports.reports.ReportKey;\n\npublic class ParamParsingUtils {\n  private ParamParsingUtils() {\n    // utility class\n  }\n\n  public static Pair<SoftwareQuality, Severity> parseImpact(String impact) {\n    String[] parts = impact.split(\"=\");\n    if (parts.length != 2) {\n      throw new IllegalArgumentException(\"Invalid impact format: \" + impact);\n    }\n    return Pair.of(SoftwareQuality.valueOf(parts[0]),\n      Severity.valueOf(parts[1]));\n  }\n\n  public static Map<ReportKey, Set<String>> parseComplianceStandardsFilter(@Nullable String param) {\n    if (param == null) {\n      return Map.of();\n    }\n\n    String decodedParam;\n    try {\n      decodedParam = URLDecoder.decode(param, StandardCharsets.UTF_8);\n    } catch (IllegalArgumentException e) {\n      throw new IllegalArgumentException(\"Can't URI decode: \" + param, e);\n    }\n\n    Map<ReportKey, Set<String>> categoriesByStandard = new HashMap<>();","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-webapi/src/main/java/org/sonar/server/common/ParamParsingUtils.java#L25-L61","documentation":"ParamParsingUtils.parseImpact parses a filter parameter expected in the exact form 'QUALITY=SEVERITY' (e.g. MAINTAINABILITY=HIGH). If the string does not split into exactly two '='-separated parts, it throws this IllegalArgumentException before attempting enum parsing.","triggerScenarios":"Calling a Web API endpoint (e.g. issue impact filters) with an impact parameter missing the '=' separator, containing multiple '=', or empty.","commonSituations":"Manual construction of query strings without URL encoding ('=' encoded as %3D issues), copying impact values from UI JSON instead of the filter string format, typos like 'MAINTAINABILITY.HIGH'.","solutions":["Pass the impact parameter as QUALITY=SEVERITY, e.g. MAINTAINABILITY=HIGH","URL-encode the value when building the query string (('=' becomes %3D is not needed here; only encode other specials))","Validate the format client-side with a regex before sending","Ensure exactly one '=' and non-empty enum names on both sides"],"exampleFix":"// before\nimpact=MAINTAINABILITY.HIGH\n// after\nimpact=MAINTAINABILITY%3DHIGH  // sent as MAINTAINABILITY=HIGH","handlingStrategy":"validation","validationCode":"function isValidImpact(impact) {\n  const m = /^[A-Z_]+=[A-Z_]+$/.exec(impact);\n  return m !== null;\n}\n// reject e.g. 'MAINTAINABILITY.HIGH' or 'MAINTAINABILITY' before sending","typeGuard":null,"tryCatchPattern":"try {\n  await api.searchIssues({ impact: impactParam });\n} catch (e) {\n  if (e.status === 400 && /Invalid impact format/.test(e.message)) {\n    throw new Error(`Bad impact '${impactParam}': use QUALITY=SEVERITY, e.g. MAINTAINABILITY=HIGH`);\n  }\n  throw e;\n}","preventionTips":["Always build the impact filter as exactly 'QUALITY=SEVERITY'","Use constants for SoftwareQuality and Severity names instead of free text","Unit-test filter serialization helpers","Encode query values with encodeURIComponent"],"tags":["java","parameter-parsing","webservice"],"backgroundTag":"invalid-argument-format","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}