SonarSource/sonarqube · error · IllegalStateException
The property ' ' is not a float value
Error message
The property '%s' is not a float value
What it means
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.
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
Example fix
// before
Float f = settings.getFloat("sonar.threshold"); // value = "12,5"
// after
settings.setProperty("sonar.threshold", "12.5");
Float f = settings.getFloat("sonar.threshold"); Defensive patterns
Strategy: validation
Validate before calling
// validate before calling getFloat
String v = settings.getString(key);
if (v != null && !v.trim().isEmpty()) {
try { Float.valueOf(v.trim()); }
catch (NumberFormatException e) {
throw new IllegalArgumentException("property " + key + " must be a float, got: " + v);
}
} Try / catch
try {
return settings.getFloat(key);
} catch (IllegalStateException e) {
log.warn("Non-float value for {} - using default", key, e);
return defaultValue;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Users typing values with commas as decimal separators in sonar.properties or the UI; typos in numeric thresholds; values set programmatically from unvalidated input.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- The property ' ' is not a double value
- Address in property is not a valid address
- allowAllGroups can only be enabled when Auto-provisioning…
- allowAllGroups cannot be enabled when the GitLab URL is…
- allowedGroups cannot be empty when Auto-provisioning is…
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/5c0bc9e47dfd51d3.
Report an issue: GitHub.
Appendix: source
Thrown at sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Settings.java:244
}
return null;
}
/**
* Effective value as {@code Float}.
*
* @return the value as {@code Float}. If the property does not have value nor default value, then {@code null} is returned.
* @throws NumberFormatException if value is not empty and is not a parsable number
*/
@CheckForNull
@Override
public Float getFloat(String key) {
String value = getString(key);
if (StringUtils.isNotEmpty(value)) {
try {
return Float.valueOf(value);
} catch (NumberFormatException e) {
throw new IllegalStateException(String.format("The property '%s' is not a float value", key));
}
}
return null;
}
/**
* Effective value as {@code Double}.
*
* @return the value as {@code Double}. If the property does not have value nor default value, then {@code null} is returned.
* @throws NumberFormatException if value is not empty and is not a parsable number
*/
@CheckForNull
@Override
public Double getDouble(String key) {
String value = getString(key);
if (StringUtils.isNotEmpty(value)) {
try {
return Double.valueOf(value);View on GitHub (pinned to 184c821202)