{"record":{"id":"eceaec86d39bd852","repo":"JetBrains/intellij-community","slug":"attribute-attributename-is-required-element","errorCode":null,"errorMessage":"attribute '{attributeName}' is required: {element}","messagePattern":"attribute '(.+?)' is required: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"java/compiler/forms-compiler/src/com/intellij/uiDesigner/lw/LwXmlReader.java","lineNumber":51,"sourceCode":"\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){\n      return value;\n    }\n    else{\n      throw new IllegalArgumentException(\"attribute '\" + attributeName + \"' is required: \"+element);\n    }\n  }\n\n  static String getOptionalString(final Element element, final String attributeName, final String defaultValue) {\n    final String value = element.getAttributeValue(attributeName);\n    return value != null ? value.trim() : defaultValue;\n  }\n\n  public static int getRequiredInt(final Element element, final String attributeName) {\n    final String str = getRequiredString(element, attributeName);\n    try {\n      return Integer.parseInt(str);\n    }\n    catch (NumberFormatException e) {\n      throw new IllegalArgumentException(\"attribute '\" + attributeName + \"' is not a proper integer: \" + str);\n    }\n  }\n","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/compiler/forms-compiler/src/com/intellij/uiDesigner/lw/LwXmlReader.java#L33-L69","documentation":"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.","triggerScenarios":"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.","commonSituations":"Hand-editing form files and dropping attributes; XML generators omitting optional-looking but required attributes; forms converted between versions losing attributes.","solutions":["Add the named attribute to the element shown in the message with a valid value.","Re-open the form in the GUI designer and re-save it; the designer writes all required attributes.","Compare with a known-good .form file of the same component/layout type to see the expected attribute set."],"exampleFix":"<!-- before -->\n<constraints><splitpane/></constraints>\n\n<!-- after -->\n<constraints><splitpane position=\"left\"/></constraints>","handlingStrategy":"validation","validationCode":"// Before reading a required attribute\nString v = element.getAttributeValue(attr);\nif (v == null || v.trim().isEmpty()) throw new IllegalStateException(\"Missing required attribute '\" + attr + \"' on <\" + element.getName() + \">\");","typeGuard":null,"tryCatchPattern":"try { LwXmlReader.getRequiredString(element, attr); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"is required\")) { /* add the named attribute */ } else throw e; }","preventionTips":["After editing form XML, open it in the GUI designer as a validation pass.","Keep required attributes (position, row, column, id) populated when templating forms."],"tags":["gui-designer","form-xml","xml-parse","missing-attribute"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}