JetBrains/intellij-community · error · IllegalArgumentException

subtag '{childName}' is required: {element}

Error message

subtag '{childName}' is required: {element}

What it means

Thrown by LwXmlReader.getRequiredChild when the named child element does not exist under the given element in form XML. It is the generic 'mandatory subtag missing' error for structural form parsing — e.g. a component lacking its <constraints> child — and reports both the expected child name and the parent element.

Source

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

public final class LwXmlReader {
  private LwXmlReader() {
  }

  /**
   * @return can be {@code null}.
   */
  public static Element getChild(final Element element, final String childName) {
    return element.getChild(childName, element.getNamespace());
  }

  /**
   * @return never {@code null}.
   */
  static Element getRequiredChild(final Element element, final String childName) {
    final Element child = getChild(element, childName);
    if(child == null){
      throw new IllegalArgumentException("subtag '" + childName + "' is required: "+element);
    }
    return child;
  }

  /**
   * @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){

View on GitHub (pinned to be881553f2)

Solutions

  1. Read the message: it names the missing subtag and shows the parent element; add the required child element with the expected name.
  2. Re-drop or re-configure the component in the GUI designer so it regenerates the constraints structure.
  3. If generating form XML programmatically, model it on a designer-produced file for the same component type.

Example fix

<!-- before -->
<component id="btn1" class="javax.swing.JButton" binding="myBtn"/>

<!-- after -->
<component id="btn1" class="javax.swing.JButton" binding="myBtn">
  <constraints/>
</component>
Defensive patterns

Strategy: validation

Validate before calling

// Before reading required children, assert presence with a clearer error
Element child = element.getChild(childName, element.getNamespace());
if (child == null) throw new IllegalStateException("Form element <" + element.getName() + "> is missing required child <" + childName + "> at line " + element.getLineNumber());

Try / catch

try { LwXmlReader.getRequiredChild(element, name); } catch (IllegalArgumentException e) { if (e.getMessage().contains("is required")) { /* add the missing subtag named in the message */ } else throw e; }

Prevention

When it happens

Trigger: Any call like getRequiredChild(componentElement, "constraints") where the component XML has no <constraints> child; typical for splitpane/tabbedPane/grid constraint readers (LwSplitPane, LwTabbedPane, GridColumnSerializer) that require their constraint subtag under <constraints>.

Common situations: Hand-edited or tool-generated form XML with deleted constraint sections; forms from older/newer designer versions whose constraint structure differs; components pasted into XML without their constraints.

Related errors


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