{"record":{"id":"81534c92aa97858b","repo":"JetBrains/intellij-community","slug":"subtag-childname-is-required-element","errorCode":null,"errorMessage":"subtag '{childName}' is required: {element}","messagePattern":"subtag '(.+?)' is required: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"java/compiler/forms-compiler/src/com/intellij/uiDesigner/lw/LwXmlReader.java","lineNumber":29,"sourceCode":"\npublic final class LwXmlReader {\n  private LwXmlReader() {\n  }\n\n  /**\n   * @return can be {@code null}.\n   */\n  public static Element getChild(final Element element, final String childName) {\n    return element.getChild(childName, element.getNamespace());\n  }\n\n  /**\n   * @return never {@code null}.\n   */\n  static Element getRequiredChild(final Element element, final String childName) {\n    final Element child = getChild(element, childName);\n    if(child == null){\n      throw new IllegalArgumentException(\"subtag '\" + childName + \"' is required: \"+element);\n    }\n    return child;\n  }\n\n  /**\n   * @return {@code null} or trimmed attribute value.\n   */\n  public static String getString(final Element element, final String attributeName){\n    final String value = element.getAttributeValue(attributeName);\n    return value != null ? value.trim() : null;\n  }\n\n  /**\n   * @return never {@code null} trimmed attribute value.\n   */\n  public static String getRequiredString(final Element element, final String attributeName) {\n    final String value = getString(element, attributeName);\n    if(value != null){","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/compiler/forms-compiler/src/com/intellij/uiDesigner/lw/LwXmlReader.java#L11-L47","documentation":"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.","triggerScenarios":"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>.","commonSituations":"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.","solutions":["Read the message: it names the missing subtag and shows the parent element; add the required child element with the expected name.","Re-drop or re-configure the component in the GUI designer so it regenerates the constraints structure.","If generating form XML programmatically, model it on a designer-produced file for the same component type."],"exampleFix":"<!-- before -->\n<component id=\"btn1\" class=\"javax.swing.JButton\" binding=\"myBtn\"/>\n\n<!-- after -->\n<component id=\"btn1\" class=\"javax.swing.JButton\" binding=\"myBtn\">\n  <constraints/>\n</component>","handlingStrategy":"validation","validationCode":"// Before reading required children, assert presence with a clearer error\nElement child = element.getChild(childName, element.getNamespace());\nif (child == null) throw new IllegalStateException(\"Form element <\" + element.getName() + \"> is missing required child <\" + childName + \"> at line \" + element.getLineNumber());","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["Never delete <constraints> blocks when hand-editing forms.","Model generated forms on designer-produced files for the same component type."],"tags":["gui-designer","form-xml","xml-parse","missing-element"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}