{"record":{"id":"75cd256fe691efbb","repo":"apache/hadoop","slug":"xattrs-are-not-supported-on-symlinks","errorCode":null,"errorMessage":"XAttrs are not supported on symlinks","messagePattern":"XAttrs are not supported on symlinks","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeSymlink.java","lineNumber":129,"sourceCode":"\n  @Override\n  public void accept(NamespaceVisitor visitor, int snapshot) {\n    visitor.visitSymlink(this, snapshot);\n  }\n\n  @Override\n  public void removeAclFeature() {\n    throw new UnsupportedOperationException(\"ACLs are not supported on symlinks\");\n  }\n\n  @Override\n  public void addAclFeature(AclFeature f) {\n    throw new UnsupportedOperationException(\"ACLs are not supported on symlinks\");\n  }\n\n  @Override\n  final XAttrFeature getXAttrFeature(int snapshotId) {\n    throw new UnsupportedOperationException(\"XAttrs are not supported on symlinks\");\n  }\n  \n  @Override\n  public void removeXAttrFeature() {\n    throw new UnsupportedOperationException(\"XAttrs are not supported on symlinks\");\n  }\n  \n  @Override\n  public void addXAttrFeature(XAttrFeature f) {\n    throw new UnsupportedOperationException(\"XAttrs are not supported on symlinks\");\n  }\n\n  @Override\n  public byte getStoragePolicyID() {\n    throw new UnsupportedOperationException(\n        \"Storage policy are not supported on symlinks\");\n  }\n","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeSymlink.java#L111-L147","documentation":"INodeSymlink.getXAttrFeature unconditionally throws UnsupportedOperationException(\"XAttrs are not supported on symlinks\"). Reading extended attributes of a symlink inode (or internal logic that consults xattrs — encryption zone markers, raw xattr namespaces) reaches this method and fails, because symlink inodes carry no XAttrFeature storage.","triggerScenarios":"getXAttrs/getXAttr on a symlink path; internal attribute lookups (e.g. encryption zone or trusted-namespace checks) operating directly on a symlink inode rather than its resolved target.","commonSituations":"Audit/security scanners enumerating xattrs recursively over trees with symlinks; tooling that reads raw.* xattrs hitting compatibility links; distcp -p preserving xattrs.","solutions":["Resolve the symlink target (FileContext/Path.resolve) and read xattrs from the destination","Skip symlinks when enumerating xattrs across a tree","Handle UnsupportedOperationException for symlinks explicitly so scans continue"],"exampleFix":"// before\nbyte[] v = fs.getXAttr(path);   // path is a symlink -> throws\n\n// after\nPath target = path.resolve(fs); // resolve link chain\nbyte[] v = fs.getXAttr(target);","handlingStrategy":"type-guard","validationCode":"FileStatus st = fs.getFileStatus(p);\nPath target = st.isSymlink() ? fs.getFileStatus(p).getSymlink() : p;\nMap<String, byte[]> xattrs = fs.getXAttrs(target);","typeGuard":"boolean xattrReadable(FileSystem fs, Path p) throws IOException {\n  return !fs.getFileStatus(p).isSymlink();\n}","tryCatchPattern":"catch (UnsupportedOperationException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"XAttrs are not supported on symlinks\")) {\n    return Collections.emptyMap();  // links carry no xattrs by design\n  }\n  throw e;\n}","preventionTips":["Resolve symlinks before xattr reads in audit/scanner tools","Treat links as xattr-less entries in enumeration code","Version your tooling against HDFS docs: xattrs exist only on files and directories"],"tags":["hdfs","xattr","symlink","unsupported-operation","namenode"],"backgroundTag":"operation-not-supported-on-file-type","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}