SonarSource/sonarqube · error · IllegalArgumentException

Unsupported value '%s' of Measure.Level can not be converted

Error message

Unsupported value '%s' of Measure.Level can not be converted to QualityGateStatus

What it means

QualityGateMeasuresStep converts the global Measure.Level into QualityGateStatus (OK/ERROR) stored in the status holder. Only OK and ERROR are handled; any other Measure.Level value reaching convert() throws an IllegalArgumentException, an internal-invariant failure in the quality gate result pipeline.

Source

Thrown at server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/QualityGateMeasuresStep.java:142

      case OK:
        return ConditionStatus.EvaluationStatus.OK;
      case ERROR:
        return ConditionStatus.EvaluationStatus.ERROR;
      default:
        throw new IllegalArgumentException(format(
          "Unsupported value '%s' of Measure.Level can not be converted to EvaluationStatus",
          globalLevel));
    }
  }

  private static org.sonar.ce.task.projectanalysis.qualitygate.QualityGateStatus convert(Measure.Level globalLevel) {
    switch (globalLevel) {
      case OK:
        return org.sonar.ce.task.projectanalysis.qualitygate.QualityGateStatus.OK;
      case ERROR:
        return org.sonar.ce.task.projectanalysis.qualitygate.QualityGateStatus.ERROR;
      default:
        throw new IllegalArgumentException(format(
          "Unsupported value '%s' of Measure.Level can not be converted to QualityGateStatus",
          globalLevel));
    }
  }

  private static Map<Condition, ConditionStatus> createStatusPerCondition(Collection<Condition> conditions, Collection<EvaluatedCondition> evaluatedConditions) {
    Map<Condition, EvaluatedCondition> evaluatedConditionPerCondition = evaluatedConditions.stream()
      .collect(Collectors.toMap(EvaluatedCondition::getCondition, Function.identity()));

    ImmutableMap.Builder<Condition, ConditionStatus> builder = ImmutableMap.builder();
    for (Condition condition : conditions) {
      EvaluatedCondition evaluatedCondition = evaluatedConditionPerCondition.get(condition);

      if (evaluatedCondition == null) {
        builder.put(condition, NO_VALUE_STATUS);
      } else {
        builder.put(condition, create(toEvaluationStatus(evaluatedCondition.getLevel()), evaluatedCondition.getActualValue()));
      }

View on GitHub (pinned to 184c821202)

Solutions

  1. Check why the quality gate evaluation produced a level other than OK/ERROR for this component
  2. Ensure the analysis pipeline order is intact (evaluation step runs before QualityGateMeasuresStep)
  3. Align SonarQube server/plugin versions to avoid enum drift
  4. Report with full stack trace if reproducible on a stock setup
Defensive patterns

Strategy: try-catch

Validate before calling

if (globalLevel != Measure.Level.OK && globalLevel != Measure.Level.ERROR) {
  throw new IllegalStateException("QualityGateStatus conversion requires OK/ERROR, got: " + globalLevel);
}

Type guard

boolean isConvertibleToQgStatus(Measure.Level level) {
  return level == Measure.Level.OK || level == Measure.Level.ERROR;
}

Try / catch

try {
  QualityGateStatus status = convert(globalLevel);
} catch (IllegalArgumentException e) {
  LOGGER.error("Failed to map Measure.Level to QualityGateStatus", e);
  throw e;
}

Prevention

When it happens

Trigger: updateQualityGateStatusHolder calls convert(globalLevel) with a level other than OK or ERROR (e.g. NONE) after conditions were evaluated.

Common situations: Same root causes as the EvaluationStatus conversion failure: quality gate evaluation leaving level NONE, version skew between modules, corrupted measure data.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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