apache/hadoop · error · IOException

Invalid HTTP DELETE operation [{0}]

Error message

Invalid HTTP DELETE operation [{0}]

What it means

HttpFSServer.delete() dispatches DELETE requests over the operations registered for the DELETE verb (DELETE, DELETESNAPSHOT, ...) and throws IOException('Invalid HTTP DELETE operation [<op>]') from the default branch for any other op value. It signals that the op either belongs to a different verb or is unknown to this server.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java:666

        AUDIT_LOG.info("[{}] recursive [{}]", path, recursive);
        FSOperations.FSDelete command =
          new FSOperations.FSDelete(path, recursive);
        JSONObject json = fsExecute(user, command);
        response = Response.ok(json).type(MediaType.APPLICATION_JSON).build();
        break;
      }
      case DELETESNAPSHOT: {
        String snapshotName = params.get(SnapshotNameParam.NAME,
            SnapshotNameParam.class);
        FSOperations.FSDeleteSnapshot command =
                new FSOperations.FSDeleteSnapshot(path, snapshotName);
        fsExecute(user, command);
        AUDIT_LOG.info("[{}] deleted snapshot [{}]", path, snapshotName);
        response = Response.ok().build();
        break;
      }
      default: {
        throw new IOException(
          MessageFormat.format("Invalid HTTP DELETE operation [{0}]",
                               op.value()));
      }
    }
    return response;
  }

  /**
   * Special binding for '/' as it is not handled by the wildcard binding.
   * @param is the inputstream for the request payload.
   * @param uriInfo the of the request.
   * @param op the HttpFS operation of the request.
   * @param request the HttpFS request.
   *
   * @return the request response.
   *
   * @throws IOException thrown if an IO error occurred. Thrown exceptions are
   *           handled by {@link HttpFSExceptionProvider}.

View on GitHub (pinned to 2add963021)

Solutions

  1. Use op=DELETE for path removal: DELETE /webhdfs/v1/path?op=DELETE&recursive=true.
  2. For snapshots confirm spelling op=DELETESNAPSHOT plus the snapshotname parameter, and that the server's version supports snapshots.
  3. Match the verb to the operation per the WebHDFS spec and verify the server's Hadoop version supports the op.

Example fix

# before
$ curl -X DELETE 'http://host:14000/webhdfs/v1/tmp/old?op=RMDIR&user.name=alice'

# after
$ curl -X DELETE 'http://host:14000/webhdfs/v1/tmp/old?op=DELETE&recursive=true&user.name=alice'
Defensive patterns

Strategy: validation

Validate before calling

Set<String> DELETE_OPS = Set.of("DELETE", "DELETESNAPSHOT");
if (!DELETE_OPS.contains(op)) {
  throw new IllegalArgumentException(op + " is not a DELETE operation");
}

Type guard

static boolean isValidDeleteOp(String op) {
  return Set.of("DELETE", "DELETESNAPSHOT").contains(op);
}

Try / catch

try {
  resp = http.delete(buildUrl(op));
} catch (IOException e) {
  if (e.getMessage() != null && e.getMessage().contains("Invalid HTTP DELETE operation")) {
    throw new IllegalArgumentException("Wrong verb or unsupported op " + op, e);
  }
  throw e;
}

Prevention

When it happens

Trigger: DELETE ?op=RMDIR (not an HttpFS op — DELETE is); DELETE ?op=RENAME (a PUT op); DELETE ?op=DELETESNAPSHOT on an older server without snapshot support; typo such as op=deletesnapshots.

Common situations: Scripts authored against a different Hadoop version; snapshot operations hitting a pre-snapshot HttpFS; REST clients that map every 'remove' action to HTTP DELETE with a guessed op name.

Related errors


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