JetBrains/intellij-community · error · IllegalArgumentException
attribute '{attributeName}' is not a proper float: {str}
Error message
attribute '{attributeName}' is not a proper float: {str} What it means
Thrown by LwXmlReader.getRequiredFloat when a required attribute fails Float.parseFloat. Float-valued attributes occur in form layout metadata; a malformed string (non-numeric, comma decimal, trailing units) produces IllegalArgumentException with the attribute name and raw value.
Source
Thrown at java/compiler/forms-compiler/src/com/intellij/uiDesigner/lw/LwXmlReader.java:120
final String str = element.getAttributeValue(attributeName);
if (str == null) {
return defaultValue;
}
try {
return Double.parseDouble(str);
}
catch (NumberFormatException e) {
throw new IllegalArgumentException("attribute '" + attributeName + "' is not a proper double: " + str);
}
}
public static float getRequiredFloat(final Element element, final String attributeName) {
final String str = getRequiredString(element, attributeName);
try {
return Float.parseFloat(str);
}
catch (NumberFormatException e) {
throw new IllegalArgumentException("attribute '" + attributeName + "' is not a proper float: " + str);
}
}
static Object getRequiredPrimitiveTypeValue(final Element element, final String attributeName, final Class valueClass) {
final String str = getRequiredString(element, attributeName);
try {
final Method method = valueClass.getMethod("valueOf", String.class);
return method.invoke(null, str);
}
catch (NumberFormatException e) {
throw new IllegalArgumentException("attribute '" + attributeName + "' is not a proper float: " + str);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
static StringDescriptor getStringDescriptor(final Element element, final String valueAttr,View on GitHub (pinned to be881553f2)
Solutions
- Set the attribute to a plain decimal number without suffixes, e.g. "1.5".
- If unsure of the expected range, check a designer-saved form using the same component.
- Avoid pasting Java source literals into form XML.
Example fix
<!-- before --> <indent sizeIncr="1.5f"/> <!-- after --> <indent sizeIncr="1.5"/>
Defensive patterns
Strategy: validation
Validate before calling
// Validate float-shaped values before parse
if (!str.trim().matches("-?\\d+(\\.\\d+)?([eE][+-]?\\d+)?[fF]?")) throw new IllegalStateException("'" + attr + "' must be a float, got: " + str);
// note: strip a trailing f/F before writing back to XML Try / catch
try { LwXmlReader.getRequiredFloat(element, attr); } catch (IllegalArgumentException e) { if (e.getMessage().contains("not a proper float")) { /* write a plain decimal without 'f' suffix */ } else throw e; } Prevention
- Form XML wants bare decimals; remove Java float suffixes.
- Use dot decimals regardless of system locale.
When it happens
Trigger: A form-XML attribute read via getRequiredFloat holds a value Float.parseFloat rejects — e.g. "thin", "1,5", "12f". Note the parse happens on the trimmed value from getRequiredString, and the attribute itself must already exist or error 53 fires first.
Common situations: Hand-edited form XML with descriptive words in numeric attributes; Java-style float literals pasted in ('1.5f'); locale-edited decimal commas.
Related errors
- attribute '{attributeName}' is not a proper integer: {str}
- attribute '{attributeName}' is not a proper double: {str}
- unexpected element: {element}
- String descriptor value required
- unexpected element: {element}
AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14).
Data as JSON: /api/errors/79a7c9780e675638.
Report an issue: GitHub.