{"record":{"id":"b02e88162770209f","repo":"apache/hadoop","slug":"path-not-found","errorCode":null,"errorMessage":"Path not found: {}","messagePattern":"Path not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirErasureCodingOp.java","lineNumber":169,"sourceCode":"      src = iip.getPath();\n      xAttrs = setErasureCodingPolicyXAttr(fsn, iip, ecPolicy);\n    } finally {\n      fsd.writeUnlock();\n    }\n    fsn.getEditLog().logSetXAttrs(src, xAttrs, logRetryCache);\n    return fsd.getAuditFileInfo(iip);\n  }\n\n  private static List<XAttr> setErasureCodingPolicyXAttr(final FSNamesystem fsn,\n      final INodesInPath srcIIP, ErasureCodingPolicy ecPolicy) throws IOException {\n    FSDirectory fsd = fsn.getFSDirectory();\n    assert fsd.hasWriteLock();\n    Preconditions.checkNotNull(srcIIP, \"INodes cannot be null\");\n    Preconditions.checkNotNull(ecPolicy, \"EC policy cannot be null\");\n    String src = srcIIP.getPath();\n    final INode inode = srcIIP.getLastINode();\n    if (inode == null) {\n      throw new FileNotFoundException(\"Path not found: \" + srcIIP.getPath());\n    }\n    if (!inode.isDirectory()) {\n      throw new IOException(\"Attempt to set an erasure coding policy \" +\n          \"for a file \" + src);\n    }\n\n    final XAttr ecXAttr;\n    DataOutputStream dOut = null;\n    try {\n      ByteArrayOutputStream bOut = new ByteArrayOutputStream();\n      dOut = new DataOutputStream(bOut);\n      WritableUtils.writeString(dOut, ecPolicy.getName());\n      ecXAttr = XAttrHelper.buildXAttr(XATTR_ERASURECODING_POLICY,\n          bOut.toByteArray());\n    } finally {\n      IOUtils.closeStream(dOut);\n    }\n    // check whether the directory already has an erasure coding policy","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirErasureCodingOp.java#L151-L187","documentation":"FileNotFoundException thrown by setErasureCodingPolicy when the resolved path has no final inode: the target directory does not exist. The EC policy is stored as an xattr on an existing inode, so resolution failure aborts before any xattr is written.","triggerScenarios":"`hdfs ec -setPolicy -path /ec/typo`; setPolicy racing with a concurrent delete of the directory; setPolicy executed before the directory is created; wrong parent in a Hive/HBase-on-HDFS layout template.","commonSituations":"Scripts that create a directory and set its policy in one job but skip `mkdir -p`; paths read from config with a missing component; multi-step provisioners where the mkdir step failed earlier.","solutions":["Create the directory first: `hdfs dfs -mkdir -p <path>`, then `hdfs ec -setPolicy -path <path>`.","Check spelling and case of every component with `hdfs dfs -ls <parent>`.","If a concurrent delete is possible, re-check existence immediately before the call and retry once."],"exampleFix":"# before\nhdfs ec -setPolicy -policy RS-6-3-1024k -path /warehouse/db/part=missing\n# -> FileNotFoundException: Path not found\n\n# after\nhdfs dfs -mkdir -p /warehouse/db/part=missing\nhdfs ec -setPolicy -policy RS-6-3-1024k -path /warehouse/db/part=missing","handlingStrategy":"validation","validationCode":"if (!fs.exists(dir)) {\n  throw new FileNotFoundException(\"Cannot set EC policy; path missing: \" + dir);\n}\ndfs.setErasureCodingPolicy(dir, policyName);","typeGuard":null,"tryCatchPattern":"try {\n  dfs.setErasureCodingPolicy(dir, policyName);\n} catch (FileNotFoundException e) {\n  fs.mkdirs(dir);                     // create then retry once\n  dfs.setErasureCodingPolicy(dir, policyName);\n}","preventionTips":["Always `mkdir -p` before `hdfs ec -setPolicy` in provisioning scripts.","Verify paths with `hdfs dfs -test -d` in shell scripts before setting policy.","Keep path constants in one place so typos fail one check, not many RPCs."],"tags":["hdfs","erasure-coding","hdfs-ec","file-not-found","xattr"],"backgroundTag":"path-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}