{"record":{"id":"25327261b9de5a99","repo":"SonarSource/sonarqube","slug":"the-rating-grid-is-incorrect-expected-something-s","errorCode":null,"errorMessage":"The rating grid is incorrect. Expected something similar to '\" + RATING_GRID_DEF_VALUES + \"' and got '\" + config.get(RATING_GRID).orElse(\"\") + \"'","messagePattern":"The rating grid is incorrect\\. Expected something similar to '\" \\+ RATING_GRID_DEF_VALUES \\+ \"' and got '\" \\+ config\\.get\\(RATING_GRID\\)\\.orElse\\(\"\"\\) \\+ \"'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server/sonar-server-common/src/main/java/org/sonar/server/measure/DebtRatingGrid.java","lineNumber":52,"sourceCode":"import static org.sonar.server.measure.Rating.C;\nimport static org.sonar.server.measure.Rating.D;\nimport static org.sonar.server.measure.Rating.E;\n\npublic final class DebtRatingGrid {\n\n  private final double[] gridValues;\n  private final EnumMap<Rating, Bounds> ratingBounds;\n\n  public DebtRatingGrid(Configuration config) {\n    try {\n      String[] grades = config.getStringArray(RATING_GRID);\n      gridValues = new double[4];\n      for (int i = 0; i < 4; i++) {\n        gridValues[i] = Double.parseDouble(grades[i]);\n      }\n      this.ratingBounds = buildRatingBounds(gridValues);\n    } catch (Exception e) {\n      throw new IllegalArgumentException(\"The rating grid is incorrect. Expected something similar to '\"\n        + RATING_GRID_DEF_VALUES + \"' and got '\" + config.get(RATING_GRID).orElse(\"\") + \"'\", e);\n    }\n  }\n\n  public DebtRatingGrid(double[] gridValues) {\n    this.gridValues = Arrays.copyOf(gridValues, gridValues.length);\n    this.ratingBounds = buildRatingBounds(gridValues);\n  }\n\n  private static EnumMap<Rating, Bounds> buildRatingBounds(double[] gridValues) {\n    checkState(gridValues.length == 4, \"Rating grid should contains 4 values\");\n    EnumMap<Rating, Bounds> ratingBounds = new EnumMap<>(Rating.class);\n    ratingBounds.put(A, new Bounds(gridValues[0]));\n    ratingBounds.put(B, new Bounds(gridValues[0], gridValues[1]));\n    ratingBounds.put(C, new Bounds(gridValues[1], gridValues[2]));\n    ratingBounds.put(D, new Bounds(gridValues[2], gridValues[3]));\n    ratingBounds.put(E, new Bounds(gridValues[3], Double.MAX_VALUE));\n    return ratingBounds;","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-server-common/src/main/java/org/sonar/server/measure/DebtRatingGrid.java#L34-L70","documentation":"DebtRatingGrid parses the RATING_GRID configuration (comma-separated percentage bounds for the 5 reliability/security ratings) into doubles and builds rating bounds. If parsing or bound building fails (wrong number of values, non-numeric, non-increasing bounds), it throws IllegalArgumentException echoing the expected default and the received value.","triggerScenarios":"sonar.technicaldebt.ratingGrid set to a value that is not exactly 4 comma-separated ascending numeric percentages, e.g. '0.05,0.15' or 'a,b,c,d'.","commonSituations":"Admin editing the rating grid in Administration > General Settings with typos or wrong separators; locale decimal commas; copying a grid from docs of a different version.","solutions":["Set the rating grid to exactly 4 comma-separated ascending decimals, e.g. the default '0.05,0.1,0.2,0.5'.","Use dots as decimal separators (parsing is via Double.parseDouble, not locale-aware).","Remove the setting to fall back to RATING_GRID_DEF_VALUES if the custom grid is not needed.","Validate the value in a settings UI/import before applying it."],"exampleFix":"// before\nsonar.technicaldebt.ratingGrid=0,05,0,10,0,20,0,50\n// after\nsonar.technicaldebt.ratingGrid=0.05,0.1,0.2,0.5","handlingStrategy":"validation","validationCode":"String grid = config.get(RATING_GRID).orElse(\"\");\nString[] parts = grid.split(\",\");\nif (parts.length != 4) throw new IllegalArgumentException(\"RATING_GRID must have 4 values\");\ndouble prev = -1;\nfor (String p : parts) { double v = Double.parseDouble(p.trim()); if (v <= prev) throw new IllegalArgumentException(\"RATING_GRID must be ascending\"); prev = v; }","typeGuard":null,"tryCatchPattern":"try { new DebtRatingGrid(config); } catch (IllegalArgumentException e) { log.error(\"Bad rating grid '{}', using default\", config.get(RATING_GRID).orElse(\"\")); grid = DebtRatingGrid.DEFAULT; }","preventionTips":["Use dot decimals, not locale commas","Exactly 4 ascending comma-separated values","Prefer the settings UI over hand-edited property files"],"tags":["configuration","validation","measures"],"backgroundTag":"invalid-config-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"}