SonarSource/sonarqube · error · IllegalArgumentException

Invalid impact format

Error message

Invalid impact format: ${impact}

What it means

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.

Solutions

  1. Pass the impact parameter as QUALITY=SEVERITY, e.g. MAINTAINABILITY=HIGH
  2. URL-encode the value when building the query string (('=' becomes %3D is not needed here; only encode other specials))
  3. Validate the format client-side with a regex before sending
  4. Ensure exactly one '=' and non-empty enum names on both sides

Example fix

// before
impact=MAINTAINABILITY.HIGH
// after
impact=MAINTAINABILITY%3DHIGH  // sent as MAINTAINABILITY=HIGH
Defensive patterns

Strategy: validation

Validate before calling

function isValidImpact(impact) {
  const m = /^[A-Z_]+=[A-Z_]+$/.exec(impact);
  return m !== null;
}
// reject e.g. 'MAINTAINABILITY.HIGH' or 'MAINTAINABILITY' before sending

Try / catch

try {
  await api.searchIssues({ impact: impactParam });
} catch (e) {
  if (e.status === 400 && /Invalid impact format/.test(e.message)) {
    throw new Error(`Bad impact '${impactParam}': use QUALITY=SEVERITY, e.g. MAINTAINABILITY=HIGH`);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling a Web API endpoint (e.g. issue impact filters) with an impact parameter missing the '=' separator, containing multiple '=', or empty.

Common situations: 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'.

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


AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09). Data as JSON: /api/errors/7b3c14d011093639. Report an issue: GitHub.

Appendix: source

Thrown at server/sonar-webserver-webapi/src/main/java/org/sonar/server/common/ParamParsingUtils.java:43

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.apache.commons.lang3.tuple.Pair;
import org.sonar.api.issue.impact.Severity;
import org.sonar.api.issue.impact.SoftwareQuality;
import org.sonarsource.compliancereports.reports.ReportKey;

public class ParamParsingUtils {
  private ParamParsingUtils() {
    // utility class
  }

  public static Pair<SoftwareQuality, Severity> parseImpact(String impact) {
    String[] parts = impact.split("=");
    if (parts.length != 2) {
      throw new IllegalArgumentException("Invalid impact format: " + impact);
    }
    return Pair.of(SoftwareQuality.valueOf(parts[0]),
      Severity.valueOf(parts[1]));
  }

  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<>();

View on GitHub (pinned to 184c821202)