{"record":{"id":"909250418c6bd520","repo":"apache/hadoop","slug":"gettrashroots-is-not-supported-for-httpfs-on-0","errorCode":null,"errorMessage":"getTrashRoots is not supported for HttpFs on {0}. Please check your fs.defaultFS configuration","messagePattern":"getTrashRoots is not supported for HttpFs on (.+?)\\. Please check your fs\\.defaultFS configuration","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":400,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/FSOperations.java","lineNumber":2419,"sourceCode":"   * Executor that performs a FSGetTrashRoots operation.\n   */\n  @InterfaceAudience.Private\n  public static class FSGetTrashRoots\n      implements FileSystemAccess.FileSystemExecutor<Map> {\n    final private boolean allUsers;\n\n    public FSGetTrashRoots(boolean allUsers) {\n      this.allUsers = allUsers;\n    }\n\n    @Override\n    public Map execute(FileSystem fs) throws IOException {\n      Map<String, Collection<FileStatus>> paths = new HashMap<>();\n      if (fs instanceof DistributedFileSystem) {\n        DistributedFileSystem dfs = (DistributedFileSystem) fs;\n        paths.put(\"Paths\", dfs.getTrashRoots(allUsers));\n      } else {\n        throw new UnsupportedOperationException(\"getTrashRoots is \" +\n            \"not supported for HttpFs on \" + fs.getClass() +\n            \". Please check your fs.defaultFS configuration\");\n      }\n      HttpFSServerWebApp.get().getMetrics().incrOpsTrashRoots();\n      return paths;\n    }\n  }\n}","sourceCodeStart":2401,"sourceCodeEnd":2427,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/FSOperations.java#L2401-L2427","documentation":"HttpFS's GETTRASHROOTS executor delegates to DistributedFileSystem.getTrashRoots(), which resolves per-user .Trash locations and exists only on HDFS. If the FileSystem that the server's fs.defaultFS resolves to is not a DistributedFileSystem, the executor throws UnsupportedOperationException with the concrete class name as {0}.","triggerScenarios":"GET http://host:14000/webhdfs/v1/?op=GETTRASHROOTS&allusers=true (or allusers=false) against an HttpFS server whose fs.defaultFS is file:///, an object-store scheme, or another WebHDFS URL, so the created FileSystem is not DistributedFileSystem.","commonSituations":"Same family as other HDFS-only ops: default file:/// fs.defaultFS in dev setups, HttpFS placed in front of S3A/ABFS, HttpFS chained to WebHDFS, or the HDFS core-site.xml missing from the HttpFS configuration directory after an upgrade.","solutions":["Set fs.defaultFS to hdfs://namenode:8020 in the HttpFS server's core configuration and restart HttpFS.","Check the class name in the message to see which FileSystem was instantiated; fix the scheme accordingly (file:/// -> LocalFileSystem, http(s):// -> WebHdfsFileSystem).","For non-HDFS backends, compute trash roots client-side (e.g. FileSystem.getTrashRoot) instead of using op=GETTRASHROOTS."],"exampleFix":"// client: guard before calling\nFileSystem fs = FileSystem.get(conf);\nif (!(fs instanceof DistributedFileSystem)) {\n  throw new IllegalStateException(\"GETTRASHROOTS requires an HDFS backend, got \" + fs.getClass());\n}\nCollection<FileStatus> roots = ((DistributedFileSystem) fs).getTrashRoots(true);","handlingStrategy":"type-guard","validationCode":"// server-side / embedder: verify backend before exposing the op\nFileSystem fs = FileSystem.get(conf);\nif (!(fs instanceof DistributedFileSystem)) {\n  throw new IllegalStateException(\"GETTRASHROOTS requires HDFS; fs.defaultFS resolves to \" + fs.getUri());\n}","typeGuard":"static boolean supportsTrashRoots(FileSystem fs) {\n  return fs instanceof DistributedFileSystem;\n}","tryCatchPattern":"try {\n  Map trash = httpFsClient.getTrashRoots(allUsers);\n} catch (UnsupportedOperationException e) {\n  LOG.warn(\"HttpFS backend does not support getTrashRoots: {}\", e.getMessage());\n  // fall back to per-user FileSystem#getTrashRoot on the client\n}","preventionTips":["Pin fs.defaultFS to hdfs:// in the HttpFS conf dir and monitor for drift.","Smoke-test HDFS-only ops after any backend config change.","For non-HDFS backends use client-side trash root resolution instead of the REST op."],"tags":["hdfs","httpfs","webhdfs","trash","fs-defaultfs","configuration","unsupported-operation"],"backgroundTag":"unsupported-filesystem-operation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}