{"record":{"id":"413289e285abdee2","repo":"apache/hadoop","slug":"at-least-one-of-the-attributes-provided-was-not-fo","errorCode":null,"errorMessage":"At least one of the attributes provided was not found.","messagePattern":"At least one of the attributes provided was not found\\.","errorType":"exception","errorClass":"XAttrNotFoundException","httpStatus":null,"severity":"warning","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java","lineNumber":118,"sourceCode":"    checkXAttrsConfigFlag(fsd);\n    final boolean isRawPath = FSDirectory.isReservedRawName(src);\n    boolean getAll = xAttrs == null || xAttrs.isEmpty();\n    if (!getAll) {\n      XAttrPermissionFilter.checkPermissionForApi(pc, xAttrs, isRawPath);\n    }\n    final INodesInPath iip = fsd.resolvePath(pc, src, DirOp.READ);\n    if (fsd.isPermissionEnabled()) {\n      fsd.checkPathAccess(pc, iip, FsAction.READ);\n    }\n    List<XAttr> all = FSDirXAttrOp.getXAttrs(fsd, iip);\n    List<XAttr> filteredAll = XAttrPermissionFilter.\n        filterXAttrsForApi(pc, all, isRawPath);\n\n    if (getAll) {\n      return filteredAll;\n    }\n    if (filteredAll == null || filteredAll.isEmpty()) {\n      throw new XAttrNotFoundException();\n    }\n    List<XAttr> toGet = Lists.newArrayListWithCapacity(xAttrs.size());\n    for (XAttr xAttr : xAttrs) {\n      boolean foundIt = false;\n      for (XAttr a : filteredAll) {\n        if (xAttr.getNameSpace() == a.getNameSpace() && xAttr.getName().equals(\n            a.getName())) {\n          toGet.add(a);\n          foundIt = true;\n          break;\n        }\n      }\n      if (!foundIt) {\n        throw new XAttrNotFoundException();\n      }\n    }\n    return toGet;\n  }","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java#L100-L136","documentation":"getXAttrs with a name list first filters the inode's xattrs down to what the caller may see (XAttrPermissionFilter). If nothing survives, because the file has no xattrs at all or only restricted-namespace entries the caller cannot read, filteredAll is empty and the request fails with XAttrNotFoundException instead of returning an empty list.","triggerScenarios":"fs.getXAttr(path, name) or the multi-name getXAttrs on a file with no visible xattrs; typical when probing raw./trusted./security. namespaces without the privileges that let those attributes pass the filter.","commonSituations":"Probing optional metadata markers that may or may not exist; non-privileged readers of files whose only xattrs live in restricted namespaces.","solutions":["Call fs.listXAttrs(path) first and request only names it returns; an empty list means none, handle as absent","Catch XAttrNotFoundException (an IOException subclass) and treat it as attribute-absent","Run with owner or superuser privileges if restricted-namespace xattrs are genuinely expected"],"exampleFix":"// before\nbyte[] v = fs.getXAttr(path, \"user.mytag\"); // throws on xattr-less file\n\n// after\nbyte[] v = null;\nif (fs.listXAttrs(path).contains(\"user.mytag\")) {\n  v = fs.getXAttr(path, \"user.mytag\");\n}","handlingStrategy":"validation","validationCode":"List<String> present = fs.listXAttrs(path);\nif (!present.contains(\"user.mytag\")) {\n  return Optional.empty();\n}\nreturn Optional.of(fs.getXAttr(path, \"user.mytag\"));","typeGuard":null,"tryCatchPattern":"try {\n  return Optional.of(fs.getXAttr(path, name));\n} catch (XAttrNotFoundException e) {\n  return Optional.empty(); // attribute absent: not an error for optional metadata\n}","preventionTips":["Treat xattrs as optional metadata: list first or catch not-found","Remember privileges filter raw/trusted/security namespaces out of the API view","Use the user. namespace for application metadata"],"tags":["hdfs","xattr","not-found","permissions"],"backgroundTag":"xattr-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}