{"record":{"id":"50ee824fdad679ef","repo":"apache/hadoop","slug":"filesystem-item-fs-geturi-does-not-support-er","errorCode":null,"errorMessage":"FileSystem ${item.fs.getUri()} does not support Erasure Coding","messagePattern":"FileSystem (.+?) does not support Erasure Coding","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Ls.java","lineNumber":236,"sourceCode":"  @VisibleForTesting\n  boolean isUseAtime() {\n    return this.useAtime;\n  }\n\n  /**\n   * Should EC policies be displayed.\n   * @return true display EC policies, false doesn't display EC policies\n   */\n  @VisibleForTesting\n  boolean isDisplayECPolicy() {\n    return this.displayECPolicy;\n  }\n\n  @Override\n  protected void processPathArgument(PathData item) throws IOException {\n    if (isDisplayECPolicy() && item.fs.getContentSummary(item.path)\n        .getErasureCodingPolicy() == null) {\n      throw new UnsupportedOperationException(\"FileSystem \"\n          + item.fs.getUri() + \" does not support Erasure Coding\");\n    }\n\n    // implicitly recurse once for cmdline directories\n    if (dirRecurse && item.stat.isDirectory()) {\n      recursePath(item);\n    } else {\n      super.processPathArgument(item);\n    }\n  }\n\n  @Override\n  protected boolean isSorted() {\n    // use the non-iterative method for listing because explicit sorting is\n    // required based on time/size/reverse or Total number of entries\n    // required to print summary first when non-recursive.\n    return !isRecursive() || isOrderTime() || isOrderSize() || isOrderReverse();\n  }","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Ls.java#L218-L254","documentation":"UnsupportedOperationException thrown by Ls.processPathArgument (Ls.java:236) when 'hadoop fs -ls -e' (display Erasure Coding policy) is used on a path whose ContentSummary reports a null erasure coding policy — i.e. the FileSystem does not support EC. Only HDFS reports EC policies (HDFS-EC, Hadoop 3.0+); local, viewfs, and object-store filesystems return null, and the shell refuses the listing rather than printing an empty policy column.","triggerScenarios":"'hadoop fs -ls -e file:///data' or 'hadoop fs -ls -e /mnt/viewfs-path' where the resolved FS is not HDFS; 'hdfs dfs -ls -e' against an HDFS 2.x-era cluster whose getContentSummary lacks EC; scripts reusing -e unconditionally across mixed-scheme paths.","commonSituations":"Admin scripts written on an EC-enabled HDFS 3 cluster reused against local paths or an older cluster; checking EC status of a path mounted via viewfs or har:; dashboards listing many URIs with one shared flag set.","solutions":["Drop the -e flag for non-HDFS filesystems: plain 'hadoop fs -ls /path'","Query EC properly on HDFS with 'hdfs ec -getPolicy -path /path'","In code, catch UnsupportedOperationException and fall back to a normal listing without the EC column","Gate the flag by scheme: apply -e only when 'hdfs'.equals(item.fs.getUri().getScheme())"],"exampleFix":"# before\nhadoop fs -ls -e file:///data/ec-dirs    # UnsupportedOperationException\n\n# after\nhadoop fs -ls file:///data/ec-dirs\n# EC info only on HDFS:\nhdfs ec -getPolicy -path /data/ec-dirs","handlingStrategy":"try-catch","validationCode":"if (displayECPolicy\n    && fs.getContentSummary(path).getErasureCodingPolicy() == null) {\n  throw new UnsupportedOperationException(\n      \"FileSystem \" + fs.getUri() + \" does not support Erasure Coding\");\n}","typeGuard":"static boolean supportsErasureCodingPolicy(FileSystem fs) {\n  // only HDFS reports an EC policy via ContentSummary\n  return \"hdfs\".equals(fs.getUri().getScheme());\n}","tryCatchPattern":"try {\n  // listing with EC column\n} catch (UnsupportedOperationException e) {\n  // fall back to a plain listing without the EC policy column\n}","preventionTips":["Gate -ls -e on the hdfs scheme; drop it for file://, viewfs:, object stores","Use 'hdfs ec -getPolicy -path' for authoritative EC status","Catch UnsupportedOperationException when reusing listing code across schemes"],"tags":["hadoop","ls","erasure-coding","unsupported-operation","shell","hdfs"],"backgroundTag":"unsupported-filesystem-operation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}