SonarSource/sonarqube · error · IllegalStateException

format("Invalid edition found in ' ': ' '"…

Error message

format("Invalid edition found in '%s': '%s'", EDITION_FILE_PATH, str)

What it means

parseEdition converts the trimmed, uppercased content of sonar-edition.txt into a SonarEdition enum via valueOf. If the file contains a value that is not a valid enum constant, it throws IllegalStateException with the file path and offending string. This guards against corrupted or hand-edited metadata files.

Solutions

  1. Restore sonar-edition.txt to a valid value (e.g. COMMUNITY, DEVELOPER, ENTERPRISE, DATACENTER).
  2. Reinstall/upgrade the SonarQube distribution so metadata matches the plugin-api version.
  3. If writing the file yourself, ensure the exact enum constant name with no surrounding whitespace or punctuation.

Example fix

// before (sonar-edition.txt)
community-edition

// after
COMMUNITY
Defensive patterns

Strategy: validation

Validate before calling

// Java
String str = trimToEmpty(content.toUpperCase(Locale.ENGLISH));
boolean valid = Arrays.stream(SonarEdition.values()).anyMatch(e -> e.name().equals(str));
if (!valid) throw new IllegalStateException("Unknown edition value: " + str);

Try / catch

// Java
try {
  SonarEdition edition = runtime.getEdition();
} catch (IllegalStateException e) {
  // restore/repair sonar-edition.txt
}

Prevention

When it happens

Trigger: Calling loadEdition (which calls parseEdition) when sonar-edition.txt contains text that is not one of the SonarEdition constants (e.g. "COMMUNITYX", extra punctuation, unsupported edition names from a different SonarQube version).

Common situations: Hand-edited or truncated edition metadata file; SonarQube version newer than the plugin-api whose edition constant is unknown to the older enum; deployment scripts writing placeholder text into the file.

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/411df6531b44293d. Report an issue: GitHub.

Appendix: source

Thrown at sonar-plugin-api-impl/src/main/java/org/sonar/api/internal/MetadataLoader.java:104

  public static SonarEdition loadEdition(System2 system) {
    URL url = system.getResource(EDITION_FILE_PATH);
    if (url == null) {
      return SonarEdition.COMMUNITY;
    }
    try (Scanner scanner = new Scanner(url.openStream(), StandardCharsets.UTF_8)) {
      String editionInFile = scanner.nextLine();
      return parseEdition(editionInFile);
    } catch (IOException e) {
      throw new IllegalStateException(format(CAN_NOT_LOAD_FROM_CLASSPATH, EDITION_FILE_PATH), e);
    }
  }

  static SonarEdition parseEdition(String edition) {
    String str = trimToEmpty(edition.toUpperCase(Locale.ENGLISH));
    try {
      return SonarEdition.valueOf(str);
    } catch (IllegalArgumentException e) {
      throw new IllegalStateException(format("Invalid edition found in '%s': '%s'", EDITION_FILE_PATH, str));
    }
  }
}

View on GitHub (pinned to 184c821202)