{"record":{"id":"1d05f025c144c729","repo":"SonarSource/sonarqube","slug":"the-severity-is-invalid","errorCode":null,"errorMessage":"The severity is invalid","messagePattern":"The severity is invalid","errorType":"http","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/RuleUpdater.java","lineNumber":182,"sourceCode":"      throw new IllegalArgumentException(\"The name is missing\");\n    }\n    rule.setName(name);\n  }\n\n  private void updateDescription(RuleUpdate update, RuleDto rule) {\n    String description = update.getMarkdownDescription();\n    if (isNullOrEmpty(description)) {\n      throw new IllegalArgumentException(\"The description is missing\");\n    }\n    RuleDescriptionSectionDto descriptionSectionDto = createDefaultRuleDescriptionSection(uuidFactory.create(), description);\n    rule.setDescriptionFormat(RuleDto.Format.MARKDOWN);\n    rule.replaceRuleDescriptionSectionDtos(List.of(descriptionSectionDto));\n  }\n\n  private static void updateSeverity(RuleUpdate update, RuleDto rule) {\n    String severity = update.getSeverity();\n    if (isNullOrEmpty(severity) || !Severity.ALL.contains(severity)) {\n      throw new IllegalArgumentException(\"The severity is invalid\");\n    }\n    rule.setSeverity(severity);\n    updateImpactSeverity(rule, severity);\n  }\n\n  private static void updateStatus(RuleUpdate update, RuleDto rule) {\n    RuleStatus status = update.getStatus();\n    if (status == null) {\n      throw new IllegalArgumentException(\"The status is missing\");\n    }\n    rule.setStatus(status);\n  }\n\n  private static void updateTags(RuleUpdate update, RuleDto rule) {\n    Set<String> tags = update.getTags();\n    if (tags == null || tags.isEmpty()) {\n      rule.setTags(Collections.emptySet());\n    } else {","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/RuleUpdater.java#L164-L200","documentation":"RuleUpdater.updateSeverity checks that the severity string is non-empty and one of the values in Severity.ALL; any other value (or null) throws IllegalArgumentException('The severity is invalid'). This protects RuleDto from storing an unrecognized severity.","triggerScenarios":"Calling api/rules/update with 'severity' set to a value outside INFO/MINOR/MAJOR/CRITICAL/BLOCKER (e.g. lowercase 'major', 'HIGH', or an impact-style severity like 'LOW').","commonSituations":"Confusing old-style severities with impact severities (MEDIUM/HIGH/LOW) after migrating to the impacts model; case sensitivity mistakes; scripts using severity names from other tools (Checkmarx, Fortify).","solutions":["Use exactly one of INFO, MINOR, MAJOR, CRITICAL, BLOCKER (uppercase)","If you intend impact-based severities, use the 'impacts' parameter (e.g. impacts=SECURITY>HIGH) instead of 'severity'","Normalize/uppercase the severity in client code and validate against the allowed set before sending"],"exampleFix":"// before\nPOST api/rules/update?key=java:S2076&severity=high\n// after\nPOST api/rules/update?key=java:S2076&severity=CRITICAL","handlingStrategy":"validation","validationCode":"const VALID = [\"INFO\",\"MINOR\",\"MAJOR\",\"CRITICAL\",\"BLOCKER\"];\nif (severity != null && !VALID.includes(String(severity).toUpperCase())) {\n  throw new Error(`Invalid severity '${severity}'. Use one of ${VALID.join(\",\")}`);\n}","typeGuard":"function isValidSeverity(s) {\n  return [\"INFO\",\"MINOR\",\"MAJOR\",\"CRITICAL\",\"BLOCKER\"].includes(s);\n}","tryCatchPattern":"try {\n  await post(\"api/rules/update\", { key, severity });\n} catch (e) {\n  if (String(e.message).includes(\"The severity is invalid\")) {\n    console.error(`'${severity}' is not a classic severity; use INFO..BLOCKER or the impacts parameter`);\n  }\n}","preventionTips":["Use uppercase classic severity names: INFO, MINOR, MAJOR, CRITICAL, BLOCKER","Do not mix impact severities (LOW/MEDIUM/HIGH) into the severity parameter","Centralize severity constants in one validated enum in your tooling"],"tags":["sonarqube","rules","severity","enum-validation"],"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"}