{"record":{"id":"77b13fca23d408f4","repo":"apache/hadoop","slug":"invalid-value-for-fsaction","errorCode":null,"errorMessage":"Invalid value for FsAction","messagePattern":"Invalid value for FsAction","errorType":"exception","errorClass":"org.apache.hadoop.hdfs.util.XMLUtils.InvalidXmlException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java","lineNumber":5548,"sourceCode":"        Short.toString(mode.toShort()));\n  }\n\n  public static FsPermission fsPermissionFromXml(Stanza st)\n      throws InvalidXmlException {\n    short mode = Short.parseShort(st.getValue(\"MODE\"));\n    return new FsPermission(mode);\n  }\n\n  private static void fsActionToXml(ContentHandler contentHandler, FsAction v)\n      throws SAXException {\n    XMLUtils.addSaxString(contentHandler, \"PERM\", v.SYMBOL);\n  }\n\n  private static FsAction fsActionFromXml(Stanza st)\n      throws InvalidXmlException {\n    FsAction v = FSACTION_SYMBOL_MAP.get(st.getValue(\"PERM\"));\n    if (v == null)\n      throw new InvalidXmlException(\"Invalid value for FsAction\");\n    return v;\n  }\n\n  private static void appendAclEntriesToXml(ContentHandler contentHandler,\n      List<AclEntry> aclEntries) throws SAXException {\n    for (AclEntry e : aclEntries) {\n      contentHandler.startElement(\"\", \"\", \"ENTRY\", new AttributesImpl());\n      XMLUtils.addSaxString(contentHandler, \"SCOPE\", e.getScope().name());\n      XMLUtils.addSaxString(contentHandler, \"TYPE\", e.getType().name());\n      if (e.getName() != null) {\n        XMLUtils.addSaxString(contentHandler, \"NAME\", e.getName());\n      }\n      fsActionToXml(contentHandler, e.getPermission());\n      contentHandler.endElement(\"\", \"\", \"ENTRY\");\n    }\n  }\n\n  private static List<AclEntry> readAclEntriesFromXml(Stanza st) {","sourceCodeStart":5530,"sourceCodeEnd":5566,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java#L5530-L5566","documentation":"fsActionFromXml() maps the PERM element of a permission/ACL stanza to an FsAction via FSACTION_SYMBOL_MAP, which contains exactly the eight rwx combinations ('---' through 'rwx'). A missing, empty, or malformed PERM value misses the map and yields InvalidXmlException('Invalid value for FsAction').","triggerScenarios":"OfflineEditsViewer XML round-trip where PERM is absent (empty string from a missing element), uppercase ('R--'), four characters ('r-x '), or uses octal ('644') instead of the 3-char rwx symbol.","commonSituations":"Hand-edited permission entries; sed/awk scripts rewriting the XML; conversion from tools that emit octal permissions or mangle stanza nesting so PERM comes back empty.","solutions":["Fix PERM to exactly three characters matching [r-][w-][x-], e.g. 'r-x'.","Regenerate the XML from the binary edits file rather than editing permissions by hand.","If PERM is empty, check the stanza nesting — the element is probably missing or misplaced."],"exampleFix":"<!-- before: octal / padded symbols -->\n<PERM>644</PERM>\n\n<!-- after: 3-char rwx symbol -->\n<PERM>rw-</PERM>","handlingStrategy":"validation","validationCode":"String perm = st.getValue(\"PERM\");\nif (perm == null || !perm.matches(\"[r-][w-][x-]\")) {\n  throw new IllegalArgumentException(\n      \"PERM must match [r-][w-][x-]: \" + perm);\n}","typeGuard":null,"tryCatchPattern":"try {\n  FsAction a = FSEditLogOp.fsActionFromXml(st);\n} catch (InvalidXmlException e) {\n  // fix the PERM element and re-run the conversion\n}","preventionTips":["Do not edit permissions in offline-edits XML by hand.","Pre-validate PERM with a [r-][w-][x-] regex before conversion.","Prefer regenerating XML from the binary edits file."],"tags":["hdfs","offline-edits-viewer","xml","permissions","acl"],"backgroundTag":"xml-validation-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}