apache/hadoop · error · BadFormatException

Bad format: {}

Error message

Bad format: {}

What it means

Error "Bad format: {}" thrown in apache/hadoop.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NetworkTopologyServlet.java:120

    Map<String, TreeSet<String>> tree = new HashMap<>();
    for(Node dni : leaves) {
      String location = dni.getNetworkLocation();
      String name = dni.getName();

      tree.putIfAbsent(location, new TreeSet<>());
      tree.get(location).add(name);
    }

    // Sort the racks (and nodes) alphabetically, display in order
    ArrayList<String> racks = new ArrayList<>(tree.keySet());
    Collections.sort(racks);

    if (FORMAT_JSON.equals(format)) {
      printJsonFormat(stream, tree, racks);
    } else if (FORMAT_TEXT.equals(format)) {
      printTextFormat(stream, tree, racks);
    } else {
      throw new BadFormatException("Bad format: " + format);
    }
  }

  protected void printJsonFormat(PrintStream stream, Map<String,
      TreeSet<String>> tree, ArrayList<String> racks) throws IOException {
    JsonFactory dumpFactory = new JsonFactory();
    JsonGenerator dumpGenerator = dumpFactory.createGenerator(stream);
    dumpGenerator.writeStartArray();

    for(String r : racks) {
      dumpGenerator.writeStartObject();
      dumpGenerator.writeFieldName(r);
      TreeSet<String> nodes = tree.get(r);
      dumpGenerator.writeStartArray();

      for(String n : nodes) {
        dumpGenerator.writeStartObject();
        dumpGenerator.writeStringField("ip", n);

View on GitHub (pinned to 2add963021)

Solutions

  1. Use a supported format parameter for the topology servlet (e.g., the documented JSON/text formats).

When it happens

Trigger: A client requests the network topology servlet with an unknown 'format' query parameter.

Common situations: Hand-crafted HTTP requests to the NameNode web UI with an invalid format value.


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