JetBrains/intellij-community · error · IllegalArgumentException

attribute '{attributeName}' is required: {element}

Error message

attribute '{attributeName}' is required: {element}

What it means

Thrown by LwXmlReader.getRequiredString when an attribute required by the form format is absent or empty on an element. It is the generic 'mandatory attribute missing' error for form XML parsing and reports the attribute name plus the offending element, covering things like splitpane position, grid row/column indexes, and ids.

Source

Thrown at java/compiler/forms-compiler/src/com/intellij/uiDesigner/lw/LwXmlReader.java:51

  /**
   * @return {@code null} or trimmed attribute value.
   */
  public static String getString(final Element element, final String attributeName){
    final String value = element.getAttributeValue(attributeName);
    return value != null ? value.trim() : null;
  }

  /**
   * @return never {@code null} trimmed attribute value.
   */
  public static String getRequiredString(final Element element, final String attributeName) {
    final String value = getString(element, attributeName);
    if(value != null){
      return value;
    }
    else{
      throw new IllegalArgumentException("attribute '" + attributeName + "' is required: "+element);
    }
  }

  static String getOptionalString(final Element element, final String attributeName, final String defaultValue) {
    final String value = element.getAttributeValue(attributeName);
    return value != null ? value.trim() : defaultValue;
  }

  public static int getRequiredInt(final Element element, final String attributeName) {
    final String str = getRequiredString(element, attributeName);
    try {
      return Integer.parseInt(str);
    }
    catch (NumberFormatException e) {
      throw new IllegalArgumentException("attribute '" + attributeName + "' is not a proper integer: " + str);
    }
  }

View on GitHub (pinned to be881553f2)

Solutions

  1. Add the named attribute to the element shown in the message with a valid value.
  2. Re-open the form in the GUI designer and re-save it; the designer writes all required attributes.
  3. Compare with a known-good .form file of the same component/layout type to see the expected attribute set.

Example fix

<!-- before -->
<constraints><splitpane/></constraints>

<!-- after -->
<constraints><splitpane position="left"/></constraints>
Defensive patterns

Strategy: validation

Validate before calling

// Before reading a required attribute
String v = element.getAttributeValue(attr);
if (v == null || v.trim().isEmpty()) throw new IllegalStateException("Missing required attribute '" + attr + "' on <" + element.getName() + ">");

Try / catch

try { LwXmlReader.getRequiredString(element, attr); } catch (IllegalArgumentException e) { if (e.getMessage().contains("is required")) { /* add the named attribute */ } else throw e; }

Prevention

When it happens

Trigger: Any form-XML element read via getRequiredString lacking the attribute — e.g. <splitpane/> without position="left", a <grid> row without height attribute where required, or a component without its binding-related attribute when the reader requires one.

Common situations: Hand-editing form files and dropping attributes; XML generators omitting optional-looking but required attributes; forms converted between versions losing attributes.

Related errors


AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14). Data as JSON: /api/errors/eceaec86d39bd852. Report an issue: GitHub.