{"record":{"id":"e5d75bfd2357b995","repo":"apache/hadoop","slug":"policy-s-does-not-match-any-enabled-erasure-cod","errorCode":null,"errorMessage":"Policy '%s' does not match any enabled erasure coding policies: [%s]. An erasure coding policy can be enabled by enableErasureCodingPolicy API.","messagePattern":"Policy '(.+?)' does not match any enabled erasure coding policies: \\[(.+?)\\]\\. An erasure coding policy can be enabled by enableErasureCodingPolicy API\\.","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":92,"sourceCode":"      final FSNamesystem fsn, final String ecPolicyName) throws IOException {\n    assert fsn.hasReadLock(RwLockMode.FS);\n    ErasureCodingPolicy ecPolicy = fsn.getErasureCodingPolicyManager()\n        .getEnabledPolicyByName(ecPolicyName);\n    if (ecPolicy == null) {\n      final String sysPolicies =\n          Arrays.asList(\n              fsn.getErasureCodingPolicyManager().getEnabledPolicies())\n              .stream()\n              .map(ErasureCodingPolicy::getName)\n              .collect(Collectors.joining(\", \"));\n      final String message = String.format(\"Policy '%s' does not match any \" +\n              \"enabled erasure\" +\n              \" coding policies: [%s]. An erasure coding policy can be\" +\n              \" enabled by enableErasureCodingPolicy API.\",\n          ecPolicyName,\n          sysPolicies\n      );\n      throw new HadoopIllegalArgumentException(message);\n    }\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) {","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirErasureCodingOp.java#L74-L110","documentation":"Unchecked HadoopIllegalArgumentException thrown while validating an erasure coding policy name for setPolicy: the name matches none of the *enabled* policies from ErasureCodingPolicyManager.getEnabledPolicies(). A policy can exist and still be rejected - built-ins such as RS-10-4-1024k and RS-LEGACY-10-4-1024k ship disabled, and policies added via addPolicies also require an explicit enableErasureCodingPolicy call before use.","triggerScenarios":"`hdfs ec -setPolicy -policy RS-10-4-1024k -path /ec` run before `hdfs ec -enablePolicy -policy RS-10-4-1024k`; DistributedFileSystem.setErasureCodingPolicy(path, \"XOR-2-1-1024k\") after an admin disabled that policy; using a just-added custom policy right after `hdfs ec -addPolicies` without enabling it.","commonSituations":"Fresh Hadoop 3 clusters where only a subset of built-in EC policies is enabled by default; EC scripts ported from an older cluster that had extra policies enabled; an admin previously ran `hdfs ec -disablePolicy`; assuming addPolicies auto-enables new policies.","solutions":["Enable the policy first: `hdfs ec -enablePolicy -policy <name>`, then retry setPolicy.","Or switch to a policy already marked enabled in `hdfs ec -listPolicies`.","For custom schemas: `hdfs ec -addPolicies -policyFile <json>` followed by `hdfs ec -enablePolicy -policy <name>`.","If the policy should be on by default, verify the NameNode's erasure-code configuration (io.erasurecode.codecs.*, dfs.namenode.ec.system.default.policies)."],"exampleFix":"# before\nhdfs ec -setPolicy -policy RS-10-4-1024k -path /ec\n# -> HadoopIllegalArgumentException: Policy 'RS-10-4-1024k' does not match any enabled policies\n\n# after\nhdfs ec -enablePolicy -policy RS-10-4-1024k\nhdfs ec -setPolicy -policy RS-10-4-1024k -path /ec","handlingStrategy":"validation","validationCode":"import java.util.Arrays;\nimport org.apache.hadoop.hdfs.DistributedFileSystem;\n\nstatic boolean ecPolicyEnabled(DistributedFileSystem dfs, String name) throws IOException {\n  return Arrays.stream(dfs.getAllErasureCodingPolicies())\n      .anyMatch(i -> i.isEnabled() && i.getName().equals(name));\n}\n\nif (!ecPolicyEnabled(dfs, policyName)) {\n  dfs.enableErasureCodingPolicy(policyName); // or fail fast listing enabled names\n}\ndfs.setErasureCodingPolicy(dir, policyName);","typeGuard":null,"tryCatchPattern":"try {\n  dfs.setErasureCodingPolicy(dir, policyName);\n} catch (org.apache.hadoop.HadoopIllegalArgumentException e) {\n  // message names the enabled set; surface it and/or enableErasureCodingPolicy then retry\n  throw new IllegalStateException(\"EC policy not enabled: \" + policyName, e);\n}","preventionTips":["Run `hdfs ec -listPolicies` after cluster provisioning and record the enabled set.","Put enablePolicy steps in the same provisioning script as addPolicies.","Pin policy names in code to constants verified against the target cluster."],"tags":["hdfs","erasure-coding","ec-policy","hdfs-ec","hadoop-3"],"backgroundTag":"policy-not-enabled","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}