{"record":{"id":"5c0bc9e47dfd51d3","repo":"SonarSource/sonarqube","slug":"the-property-s-is-not-a-float-value","errorCode":null,"errorMessage":"The property '%s' is not a float value","messagePattern":"The property '(.+?)' is not a float value","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Settings.java","lineNumber":244,"sourceCode":"    }\n    return null;\n  }\n\n  /**\n   * Effective value as {@code Float}.\n   *\n   * @return the value as {@code Float}. If the property does not have value nor default value, then {@code null} is returned.\n   * @throws NumberFormatException if value is not empty and is not a parsable number\n   */\n  @CheckForNull\n  @Override\n  public Float getFloat(String key) {\n    String value = getString(key);\n    if (StringUtils.isNotEmpty(value)) {\n      try {\n        return Float.valueOf(value);\n      } catch (NumberFormatException e) {\n        throw new IllegalStateException(String.format(\"The property '%s' is not a float value\", key));\n      }\n    }\n    return null;\n  }\n\n  /**\n   * Effective value as {@code Double}.\n   *\n   * @return the value as {@code Double}. If the property does not have value nor default value, then {@code null} is returned.\n   * @throws NumberFormatException if value is not empty and is not a parsable number\n   */\n  @CheckForNull\n  @Override\n  public Double getDouble(String key) {\n    String value = getString(key);\n    if (StringUtils.isNotEmpty(value)) {\n      try {\n        return Double.valueOf(value);","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Settings.java#L226-L262","documentation":"Settings.getFloat retrieves the string value of a property and converts it to a Float. If the value is non-empty but not a valid float, the NumberFormatException is replaced by this IllegalStateException. The library throws it because numeric settings must be parseable and an unparseable value is a configuration error.","triggerScenarios":"Calling getFloat(key) when the property holds text like '12.5x', a localized decimal separator (e.g. comma), an empty-but-present value, or any non-numeric string.","commonSituations":"Users typing values with commas as decimal separators in sonar.properties or the UI; typos in numeric thresholds; values set programmatically from unvalidated input.","solutions":["Correct the stored value to a valid float using '.' as the decimal separator (e.g. 12.5)","Validate the value before calling getFloat (parse with Float.valueOf yourself or use a regex)","Re-save the property via UI/API with a proper numeric value","Fall back to getDefaultValue or a sane default if the property may be user-supplied"],"exampleFix":"// before\nFloat f = settings.getFloat(\"sonar.threshold\"); // value = \"12,5\"\n// after\nsettings.setProperty(\"sonar.threshold\", \"12.5\");\nFloat f = settings.getFloat(\"sonar.threshold\");","handlingStrategy":"validation","validationCode":"// validate before calling getFloat\nString v = settings.getString(key);\nif (v != null && !v.trim().isEmpty()) {\n  try { Float.valueOf(v.trim()); }\n  catch (NumberFormatException e) {\n    throw new IllegalArgumentException(\"property \" + key + \" must be a float, got: \" + v);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  return settings.getFloat(key);\n} catch (IllegalStateException e) {\n  log.warn(\"Non-float value for {} - using default\", key, e);\n  return defaultValue;\n}","preventionTips":["Always use '.' as decimal separator in settings","Validate numeric inputs before setProperty","Document accepted formats for numeric settings","Prefer PropertyDefinition validators to reject bad values at write time"],"tags":["type-conversion","configuration","number-parsing"],"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"}