{"record":{"id":"aae7f01e3e77bf16","repo":"shwenzhang/AndResGuard","slug":"invalid-config-file-missing-required-attribute","errorCode":null,"errorMessage":"Invalid config file: Missing required attribute ","messagePattern":"Invalid config file: Missing required attribute ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"AndResGuard-core/src/main/java/com/tencent/mm/resourceproguard/Configuration.java","lineNumber":264,"sourceCode":"  }\n\n  private void readWhiteListFromXml(Node node) throws IOException {\n    NodeList childNodes = node.getChildNodes();\n    if (childNodes.getLength() > 0) {\n      for (int j = 0, n = childNodes.getLength(); j < n; j++) {\n        Node child = childNodes.item(j);\n        if (child.getNodeType() == Node.ELEMENT_NODE) {\n          Element check = (Element) child;\n          String vaule = check.getAttribute(ATTR_VALUE);\n          addWhiteList(vaule);\n        }\n      }\n    }\n  }\n\n  private void addWhiteList(String item) throws IOException {\n    if (item.length() == 0) {\n      throw new IOException(\"Invalid config file: Missing required attribute \" + ATTR_VALUE);\n    }\n\n    int packagePos = item.indexOf(\".R.\");\n    if (packagePos == -1) {\n\n      throw new IOException(String.format(\"please write the full package name,eg com.tencent.mm.R.drawable.dfdf, but yours %s\\n\",\n          item\n      ));\n    }\n    //先去掉空格\n    item = item.trim();\n    String packageName = item.substring(0, packagePos);\n    //不能通过lastDot\n    int nextDot = item.indexOf(\".\", packagePos + 3);\n    String typeName = item.substring(packagePos + 3, nextDot);\n    String name = item.substring(nextDot + 1);\n    HashMap<String, HashSet<Pattern>> typeMap;\n","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/shwenzhang/AndResGuard/blob/e4df245d82f27d9a2d0dd108260a3510cbaba849/AndResGuard-core/src/main/java/com/tencent/mm/resourceproguard/Configuration.java#L246-L282","documentation":"AndResGuard's Configuration parser throws this IOException when a <item> element inside the <whitelist> section of the config XML resolves to an empty (length 0) string, i.e. the required 'value' attribute is missing or blank. The whitelist is used to keep certain resource names untouched during obfuscation, so an empty entry is meaningless and treated as a malformed config. The library fails fast at parse time rather than silently producing a broken whitelist.","triggerScenarios":"Running AndResGuard with an XML config containing <whitelist><item value=\"\"/></whitelist> or <item/> inside the whitelist issue; readWhiteListFromXml reads each item's value attribute and calls addWhiteList, which throws immediately when item.length()==0.","commonSituations":"Hand-edited config files where the value attribute was accidentally deleted or left empty; template configs with placeholder whitelist items never filled in; XML generation scripts emitting empty items for empty whitelist entries.","solutions":["Add a non-empty value attribute to every <item> under <whitelist>, e.g. <item value=\"com.example.app.R.drawable.icon\"/>","Remove the empty <item> element entirely if no whitelist entries are needed","Regenerate the config from the official sample config_file_and_resguard.xml and re-fill your values"],"exampleFix":"// before (config.xml)\n<issue id=\"whitelist\">\n  <item value=\"\"/>\n</issue>\n// after (config.xml)\n<issue id=\"whitelist\">\n  <item value=\"com.example.app.R.drawable.ic_launcher\"/>\n</issue>","handlingStrategy":"validation","validationCode":"// before running AndResGuard with config.xml\nDocument doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(configFile);\nNodeList items = doc.getElementsByTagName(\"item\");\nfor (int i = 0; i < items.getLength(); i++) {\n  Element e = (Element) items.item(i);\n  if (e.getParentNode().getNodeName().contains(\"whitelist\") && e.getAttribute(\"value\").isEmpty()) {\n    throw new IllegalStateException(\"whitelist item at index \" + i + \" has empty value\");\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  new Configuration(configFile, ...);\n} catch (IOException e) {\n  if (e.getMessage().contains(\"Missing required attribute\")) {\n    // point the user to the offending <item> in the whitelist section\n  }\n  throw e;\n}","preventionTips":["Never emit <item value=\"\"/> from config generators — skip empty entries instead","Lint your config XML for empty value attributes before the build","Keep the whitelist in source control and review edits to it"],"tags":["android","config","xml","whitelist"],"backgroundTag":"empty-required-field","analyzedSha":"e4df245d82f27d9a2d0dd108260a3510cbaba849","analyzedAt":"2026-09-12T17:49:07.798Z","contentChangedAt":"2026-09-12T17:49:07.798Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}