apache/hadoop · error · ObsException
The trash feature(fs.obs.trash.enable) is enabled, but the c
Error message
The trash feature(fs.obs.trash.enable) is enabled, but the configuration(fs.obs.trash.dir [%s]) is empty.
What it means
During OBSFileSystem.initialize, when fs.obs.trash.enable is true the connector reads fs.obs.trash.dir and requires a non-empty value; empty/missing triggers an ObsException with this message (afterwards normalized by translateException during propagation). The trash feature needs an explicit directory to move deleted objects to — there is no default — so enabling it without configuring the destination leaves the filesystem unusable. Initialization fails before any operation can run.
Source
Thrown at hadoop-cloud-storage-project/hadoop-huaweicloud/src/main/java/org/apache/hadoop/fs/obs/OBSFileSystem.java:368
if (!isFsBucket()) {
String errorMsg = String.format(
"The bucket [%s] is not posix. not supported for "
+ "trash.", bucket);
LOG.warn(errorMsg);
enableTrash = false;
trashDir = null;
} else {
trashDir = conf.get(OBSConstants.TRASH_DIR);
if (StringUtils.isEmpty(trashDir)) {
String errorMsg =
String.format(
"The trash feature(fs.obs.trash.enable) is "
+ "enabled, but the "
+ "configuration(fs.obs.trash.dir [%s]) "
+ "is empty.",
trashDir);
LOG.error(errorMsg);
throw new ObsException(errorMsg);
}
trashDir = OBSCommonUtils.maybeAddBeginningSlash(trashDir);
trashDir = OBSCommonUtils.maybeAddTrailingSlash(trashDir);
}
}
} catch (ObsException e) {
throw OBSCommonUtils.translateException("initializing ",
new Path(name), e);
}
}
private void initThreadPools(final Configuration conf) {
long keepAliveTime = OBSCommonUtils.longOption(conf,
OBSConstants.KEEPALIVE_TIME,
OBSConstants.DEFAULT_KEEPALIVE_TIME, 0);
int maxThreads = conf.getInt(OBSConstants.MAX_THREADS,
OBSConstants.DEFAULT_MAX_THREADS);View on GitHub (pinned to 2add963021)
Solutions
- Set fs.obs.trash.dir to a valid OBS path (e.g. /user/.Trash) whenever fs.obs.trash.enable=true
- Or set fs.obs.trash.enable=false (or remove it) if soft-delete behavior is not wanted
- Validate the configuration pair at deploy time with a smoke test that mounts the filesystem before jobs launch
- If configuring programmatically, assert both keys together: if enable is true, require non-empty dir before calling FileSystem.get
Example fix
// before
conf.setBoolean("fs.obs.trash.enable", true);
// fs.obs.trash.dir missing -> ObsException at initialize
// after
conf.setBoolean("fs.obs.trash.enable", true);
conf.set("fs.obs.trash.dir", "/user/.Trash"); Defensive patterns
Strategy: validation
Validate before calling
boolean trashEnabled = conf.getBoolean("fs.obs.trash.enable", false);
String trashDir = conf.get("fs.obs.trash.dir");
if (trashEnabled && (trashDir == null || trashDir.trim().isEmpty())) {
throw new IllegalStateException(
"fs.obs.trash.dir must be set when fs.obs.trash.enable=true");
}
// only then construct the OBS FileSystem Try / catch
try {
FileSystem fs = path.getFileSystem(conf);
} catch (IOException e) {
if (String.valueOf(e.getMessage()).contains("fs.obs.trash.dir")) {
// configuration error: set fs.obs.trash.dir or disable trash, then retry mount
}
throw e;
} Prevention
- Treat trash.enable and trash.dir as an inseparable config pair in templates
- Fail fast in deploy scripts on half-configured features
- Smoke-test the mount step before submitting jobs
When it happens
Trigger: Setting fs.obs.trash.enable=true in core-site.xml while fs.obs.trash.dir is absent, empty, or whitespace; enabling trash via programmatic Configuration(conf.setBoolean) but forgetting conf.set for the dir; XML templating that renders the trash.dir property with an empty ${variable}.
Common situations: Teams copying a partial OBS configuration snippet that lists trash.enable but not trash.dir; environment-specific configs where the trash directory variable is only defined in one environment; upgrades where trash was newly enabled without completing the config pair.
Related errors
- Unsupported block buffer "{}"
- getTrashRoot on path `<path>' is not within a mount point
- Failed to initialize %s
- Journal {} not formatted ; journal id: {}
- Cannot start trash emptier with negative interval. Set fs.tr
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/6df8d86341bb6268.
Report an issue: GitHub.