{"record":{"id":"411df6531b44293d","repo":"SonarSource/sonarqube","slug":"format-invalid-edition-found-in-s-s-edit","errorCode":null,"errorMessage":"format(\"Invalid edition found in '%s': '%s'\", EDITION_FILE_PATH, str)","messagePattern":"format\\(\"Invalid edition found in '(.+?)': '(.+?)'\", EDITION_FILE_PATH, str\\)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"sonar-plugin-api-impl/src/main/java/org/sonar/api/internal/MetadataLoader.java","lineNumber":104,"sourceCode":"  public static SonarEdition loadEdition(System2 system) {\n    URL url = system.getResource(EDITION_FILE_PATH);\n    if (url == null) {\n      return SonarEdition.COMMUNITY;\n    }\n    try (Scanner scanner = new Scanner(url.openStream(), StandardCharsets.UTF_8)) {\n      String editionInFile = scanner.nextLine();\n      return parseEdition(editionInFile);\n    } catch (IOException e) {\n      throw new IllegalStateException(format(CAN_NOT_LOAD_FROM_CLASSPATH, EDITION_FILE_PATH), e);\n    }\n  }\n\n  static SonarEdition parseEdition(String edition) {\n    String str = trimToEmpty(edition.toUpperCase(Locale.ENGLISH));\n    try {\n      return SonarEdition.valueOf(str);\n    } catch (IllegalArgumentException e) {\n      throw new IllegalStateException(format(\"Invalid edition found in '%s': '%s'\", EDITION_FILE_PATH, str));\n    }\n  }\n}\n","sourceCodeStart":86,"sourceCodeEnd":108,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/sonar-plugin-api-impl/src/main/java/org/sonar/api/internal/MetadataLoader.java#L86-L108","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Restore sonar-edition.txt to a valid value (e.g. COMMUNITY, DEVELOPER, ENTERPRISE, DATACENTER).","Reinstall/upgrade the SonarQube distribution so metadata matches the plugin-api version.","If writing the file yourself, ensure the exact enum constant name with no surrounding whitespace or punctuation."],"exampleFix":"// before (sonar-edition.txt)\ncommunity-edition\n\n// after\nCOMMUNITY","handlingStrategy":"validation","validationCode":"// Java\nString str = trimToEmpty(content.toUpperCase(Locale.ENGLISH));\nboolean valid = Arrays.stream(SonarEdition.values()).anyMatch(e -> e.name().equals(str));\nif (!valid) throw new IllegalStateException(\"Unknown edition value: \" + str);","typeGuard":null,"tryCatchPattern":"// Java\ntry {\n  SonarEdition edition = runtime.getEdition();\n} catch (IllegalStateException e) {\n  // restore/repair sonar-edition.txt\n}","preventionTips":["Never hand-edit files inside the SonarQube installation.","Match edition file content exactly to SonarEdition enum names (upper-case, no extra text).","Keep plugin-api version aligned with the SonarQube server version."],"tags":["enum","metadata","sonarqube-plugin"],"backgroundTag":"invalid-enum-value","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"}