{"record":{"id":"73cb3ca7c41f924b","repo":"apache/hadoop","slug":"the-given-erasure-coding-policy-does-not-exist","errorCode":null,"errorMessage":"The given erasure coding policy {} does not exist.","messagePattern":"The given erasure coding policy (.+?) does not exist\\.","errorType":"exception","errorClass":"HadoopIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirErasureCodingOp.java","lineNumber":111,"sourceCode":"    }\n    return ecPolicy;\n  }\n\n  /**\n   * Check if the ecPolicyName is valid, return the corresponding\n   * EC policy if is, including the REPLICATION EC policy.\n   * @param fsn namespace\n   * @param ecPolicyName name of EC policy to be checked\n   * @return an erasure coding policy if ecPolicyName is valid\n   * @throws IOException\n   */\n  static ErasureCodingPolicy getErasureCodingPolicyByName(\n      final FSNamesystem fsn, final String ecPolicyName) throws IOException {\n    assert fsn.hasReadLock(RwLockMode.FS);\n    ErasureCodingPolicy ecPolicy = fsn.getErasureCodingPolicyManager()\n        .getErasureCodingPolicyByName(ecPolicyName);\n    if (ecPolicy == null) {\n      throw new HadoopIllegalArgumentException(\n          \"The given erasure coding \" + \"policy \" + ecPolicyName\n              + \" does not exist.\");\n    }\n    return ecPolicy;\n  }\n\n  /**\n   * Set an erasure coding policy on the given path.\n   *\n   * @param fsn The namespace\n   * @param srcArg The path of the target directory.\n   * @param ecPolicyName The erasure coding policy name to set on the target\n   *                    directory.\n   * @param logRetryCache whether to record RPC ids in editlog for retry\n   *          cache rebuilding\n   * @return {@link FileStatus}\n   * @throws IOException\n   * @throws HadoopIllegalArgumentException if the policy is not enabled","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirErasureCodingOp.java#L93-L129","documentation":"HadoopIllegalArgumentException from getErasureCodingPolicyByName: no erasure coding policy (enabled or disabled) with the given name is registered in the NameNode's ErasureCodingPolicyManager. Unlike the 'not enabled' rejection, the name is entirely unknown - a typo, a policy never added, or one removed via removePolicy.","triggerScenarios":"`hdfs ec -setPolicy -policy RS-6-3-1044k -path /ec` (typo in the cell-size suffix); referencing a policy deleted by `hdfs ec -removePolicy`; programmatic setErasureCodingPolicy with a name copied from a different cluster; using RS-LEGACY-* names on versions where that policy was removed.","commonSituations":"Copy-pasting policy names across clusters or Hadoop versions (suffixes like 64k vs 1024k differ); stale runbooks or wiki docs; custom policies from another namespace; renamed policies after upgrades.","solutions":["List valid names with `hdfs ec -listPolicies` and use the exact spelling (including the codec and cell-size suffix).","If the policy should exist, add it: `hdfs ec -addPolicies -policyFile <json>`, then enable it.","If it was removed intentionally, update callers to an existing enabled policy."],"exampleFix":"# before\nhdfs ec -setPolicy -policy RS-6-3-1044k -path /ec   # typo\n\n# after\nhdfs ec -listPolicies | grep RS-6-3\nhdfs ec -setPolicy -policy RS-6-3-1024k -path /ec","handlingStrategy":"validation","validationCode":"import java.util.Arrays;\nimport org.apache.hadoop.hdfs.DistributedFileSystem;\n\nstatic boolean ecPolicyExists(DistributedFileSystem dfs, String name) throws IOException {\n  return Arrays.stream(dfs.getAllErasureCodingPolicies())\n      .anyMatch(i -> i.getName().equals(name));\n}\n\nif (!ecPolicyExists(dfs, policyName)) {\n  throw new IllegalArgumentException(\"Unknown EC policy \" + policyName\n      + \"; valid: \" + Arrays.toString(\n          Arrays.stream(dfs.getAllErasureCodingPolicies())\n              .map(org.apache.hadoop.io.erasurecode.ErasureCodingPolicyInfo::getName)\n              .toArray(String[]::new)));\n}","typeGuard":null,"tryCatchPattern":"try {\n  dfs.setErasureCodingPolicy(dir, policyName);\n} catch (org.apache.hadoop.HadoopIllegalArgumentException e) {\n  if (e.getMessage().contains(\"does not exist\")) { /* typo or removed policy: re-list and fix name */ }\n  throw e;\n}","preventionTips":["Copy policy names verbatim from `hdfs ec -listPolicies`, including the cell-size suffix.","Fail fast at startup by validating configured policy names against the cluster.","Avoid hand-typing policy names; load them from a checked config file."],"tags":["hdfs","erasure-coding","ec-policy","hdfs-ec","typo"],"backgroundTag":"policy-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}