apache/hadoop · error · AbfsDriverException

Invalid container name (must not contain '/'): {container}

Error message

Invalid container name (must not contain '/'): {container}

What it means

A client-side precondition in AbfsBlobClient.deleteContainer: the container argument contains '/', i.e. a path was passed where only a single container name segment is valid. Container names are flat account-level identifiers and cannot contain slashes; the call is rejected before any request is sent.

Source

Thrown at hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsBlobClient.java:2449

  /**
   * Deletes a container from the storage account using the Blob service endpoint.
   *
   * @param container name of the container to delete (must be a single path segment)
   * @param tracingContext tracing context for the REST call
   * @return REST operation representing the delete request
   * @throws AzureBlobFileSystemException if the delete operation fails
   */
  public AbfsRestOperation deleteContainer(
      final String container,
      final TracingContext tracingContext)
      throws AzureBlobFileSystemException, MalformedURLException {
    if (StringUtils.isEmpty(container)) {
      throw new AbfsDriverException(
          "Container name must not be null or empty",
          new IllegalArgumentException("container"));
    }
    if (container.contains(FORWARD_SLASH)) {
      throw new AbfsDriverException(
          "Invalid container name (must not contain '/'): " + container,
          new IllegalArgumentException(container));
    }
    final List<AbfsHttpHeader> requestHeaders = createDefaultHeaders();
    final AbfsUriQueryBuilder queryBuilder = createDefaultUriQueryBuilder();
    queryBuilder.addQuery(QUERY_PARAM_RESTYPE, CONTAINER);
    appendSASTokenToQuery(container, SASTokenProvider.DELETE_CONTAINERS_OPERATION, queryBuilder);
    final URL accountUrl = new URL(getBaseUrl().getProtocol(), getBaseUrl().getHost(), ROOT_PATH);
    final URL url = createRequestUrl(accountUrl, container, queryBuilder.toString());
    final AbfsRestOperation op = getAbfsRestOperation(
        AbfsRestOperationType.DeleteContainer,
        HTTP_METHOD_DELETE,
        url,
        requestHeaders);
    op.execute(tracingContext);
    return op;
  }
}

View on GitHub (pinned to 2add963021)

Solutions

  1. Strip to the first path segment / URI authority before calling: container names must be a single slash-free segment.
  2. Derive the container from the filesystem URI authority (text before '@') rather than from paths.
  3. Add a unit assertion for the container-name shape at the call site.

Example fix

// before
blobClient.deleteContainer("mycontainer/logs/2024", tracingContext);
// after
String container = uri.getAuthority().split("@")[0]; // "mycontainer"
blobClient.deleteContainer(container, tracingContext);
Defensive patterns

Strategy: validation

Validate before calling

String container = raw.split("/")[0];
if (container.contains("/") || container.isEmpty()) {
  throw new IllegalArgumentException("Not a container segment: " + raw);
}

Try / catch

catch (AbfsDriverException ex) {
  if (ex.getMessage().contains("must not contain '/'")) {
    // a path was passed: strip to the first segment and retry
  } else throw ex;
}

Prevention

When it happens

Trigger: Passing a fully-qualified path (e.g. 'mycontainer/dir/file' or '/mycontainer') instead of just the container segment to deleteContainer.

Common situations: Callers deriving the argument from a Path or URL and forgetting to strip to the authority's container part; helper refactors that changed what the string parameter holds.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/d4d26be2f4bb4505. Report an issue: GitHub.