{"record":{"id":"6e9d8a209f19ce9d","repo":"apache/hadoop","slug":"bad-format-6e9d8a","errorCode":null,"errorMessage":"Bad format: {}","messagePattern":"Bad format: (.+?)","errorType":"validation","errorClass":"BadFormatException","httpStatus":410,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NetworkTopologyServlet.java","lineNumber":120,"sourceCode":"    Map<String, TreeSet<String>> tree = new HashMap<>();\n    for(Node dni : leaves) {\n      String location = dni.getNetworkLocation();\n      String name = dni.getName();\n\n      tree.putIfAbsent(location, new TreeSet<>());\n      tree.get(location).add(name);\n    }\n\n    // Sort the racks (and nodes) alphabetically, display in order\n    ArrayList<String> racks = new ArrayList<>(tree.keySet());\n    Collections.sort(racks);\n\n    if (FORMAT_JSON.equals(format)) {\n      printJsonFormat(stream, tree, racks);\n    } else if (FORMAT_TEXT.equals(format)) {\n      printTextFormat(stream, tree, racks);\n    } else {\n      throw new BadFormatException(\"Bad format: \" + format);\n    }\n  }\n\n  protected void printJsonFormat(PrintStream stream, Map<String,\n      TreeSet<String>> tree, ArrayList<String> racks) throws IOException {\n    JsonFactory dumpFactory = new JsonFactory();\n    JsonGenerator dumpGenerator = dumpFactory.createGenerator(stream);\n    dumpGenerator.writeStartArray();\n\n    for(String r : racks) {\n      dumpGenerator.writeStartObject();\n      dumpGenerator.writeFieldName(r);\n      TreeSet<String> nodes = tree.get(r);\n      dumpGenerator.writeStartArray();\n\n      for(String n : nodes) {\n        dumpGenerator.writeStartObject();\n        dumpGenerator.writeStringField(\"ip\", n);","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NetworkTopologyServlet.java#L102-L138","documentation":"Error \"Bad format: {}\" thrown in apache/hadoop.","triggerScenarios":"A client requests the network topology servlet with an unknown 'format' query parameter.","commonSituations":"Hand-crafted HTTP requests to the NameNode web UI with an invalid format value.","solutions":["Use a supported format parameter for the topology servlet (e.g., the documented JSON/text formats)."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}