{"record":{"id":"9367a0b902048750","repo":"apache/hadoop","slug":"failed-to-get-server-trash-configuration","errorCode":null,"errorMessage":"Failed to get server trash configuration","messagePattern":"Failed to get server trash configuration","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Trash.java","lineNumber":97,"sourceCode":"    Path fullyResolvedPath = fs.resolvePath(p);\n    FileSystem fullyResolvedFs =\n        FileSystem.get(fullyResolvedPath.toUri(), conf);\n    // If the trash interval is configured server side then clobber this\n    // configuration so that we always respect the server configuration.\n    try {\n      long trashInterval = fullyResolvedFs.getServerDefaults(\n          fullyResolvedPath).getTrashInterval();\n      if (0 != trashInterval) {\n        Configuration confCopy = new Configuration(conf);\n        confCopy.setLong(CommonConfigurationKeysPublic.FS_TRASH_INTERVAL_KEY,\n            trashInterval);\n        conf = confCopy;\n      }\n    } catch (Exception e) {\n      // If we can not determine that trash is enabled server side then\n      // bail rather than potentially deleting a file when trash is enabled.\n      LOG.warn(\"Failed to get server trash configuration\", e);\n      throw new IOException(\"Failed to get server trash configuration\", e);\n    }\n\n    /*\n     * In HADOOP-18144, we changed getTrashRoot() in ViewFileSystem to return a\n     * viewFS path, instead of a targetFS path. moveToTrash works for\n     * ViewFileSystem now. ViewFileSystem will do path resolution internally by\n     * itself.\n     *\n     * When localized trash flag is enabled:\n     *    1). if fs is a ViewFileSystem, we can initialize Trash() with a\n     *        ViewFileSystem object;\n     *    2). When fs is not a ViewFileSystem, the only place we would need to\n     *        resolve a path is for symbolic links. However, symlink is not\n     *        enabled in Hadoop due to the complexity to support it\n     *        (HADOOP-10019).\n     */\n    if (conf.getBoolean(CONFIG_VIEWFS_TRASH_FORCE_INSIDE_MOUNT_POINT,\n        CONFIG_VIEWFS_TRASH_FORCE_INSIDE_MOUNT_POINT_DEFAULT)) {","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Trash.java#L79-L115","documentation":"Thrown by Trash.moveToAppropriateTrash (reached from 'hadoop fs -rm' via the Delete shell command when trash is enabled). Before moving anything, Hadoop asks the fully-resolved FileSystem for getServerDefaults(path).getTrashInterval() so server-side trash policy wins over client config. Any exception there is deliberately fatal: the code prefers failing over deleting a file that server-side trash might have preserved.","triggerScenarios":"'hadoop fs -rm' with fs.trash.interval > 0 against a FileSystem whose getServerDefaults throws: NameNode unreachable/RPC failure, authenticated-but-unauthorized, or a connector (object store, ViewFileSystem with a bad mount) that raises UnsupportedOperationException.","commonSituations":"Object-store connectors whose server-defaults endpoint is unsupported; transient NN outage during cleanup jobs; misconfigured fs.defaultFS or viewfs mount tables; expired Kerberos tickets during long-running cleanup.","solutions":["Read the cause chain (getCause()) - UnsupportedOperationException means the FS cannot report trash config; RPC/ConnectException means fix connectivity","Fix the underlying FileSystem access: valid fs.defaultFS, reachable NameNode, fresh Kerberos credentials, correct viewfs mounts","If the filesystem legitimately cannot report server trash config, delete with trash explicitly disabled for that path/store (e.g. -skipTrash) after confirming you accept permanent deletion"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// fail fast with context before any delete that may route through trash\ntry {\n  org.apache.hadoop.fs.FsServerDefaults d = fs.getServerDefaults(p);\n  // d.getTrashInterval() is what Trash will read\n} catch (Exception e) {\n  throw new IOException(\"Cannot determine server trash policy for \" + p\n      + \"; fix FS connectivity/config before deleting\", e);\n}","typeGuard":null,"tryCatchPattern":"try {\n  fs.delete(p, true); // 'hadoop fs -rm' equivalent\n} catch (IOException e) {\n  if (e.getMessage() != null\n      && e.getMessage().equals(\"Failed to get server trash configuration\")) {\n    Throwable c = e.getCause();\n    // UnsupportedOperationException -> FS cannot report defaults\n    // java.net.ConnectException / RemoteException -> fix NN access/auth\n  }\n}","preventionTips":["Health-check getServerDefaults during job startup, not at delete time","Keep NameNode URIs, Kerberos tickets, and viewfs mounts valid for the whole life of cleanup jobs","Know which connectors do not implement server defaults and plan -skipTrash usage for them explicitly"],"tags":["hadoop","trash","server-defaults","delete"],"backgroundTag":"server-defaults-unavailable","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}