{"record":{"id":"8d25821c1c7faf03","repo":"apache/hadoop","slug":"input-file-does-not-contain-valid-topology-data","errorCode":null,"errorMessage":"Input file does not contain valid topology data.","messagePattern":"Input file does not contain valid topology data\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-rumen/src/main/java/org/apache/hadoop/tools/rumen/ClusterTopologyReader.java","lineNumber":38,"sourceCode":"import java.io.IOException;\nimport java.io.InputStream;\n\nimport org.apache.hadoop.conf.Configuration;\nimport org.apache.hadoop.fs.Path;\n\n/**\n * Reading JSON-encoded cluster topology and produce the parsed\n * {@link LoggedNetworkTopology} object.\n */\npublic class ClusterTopologyReader {\n  private LoggedNetworkTopology topology;\n\n  private void readTopology(JsonObjectMapperParser<LoggedNetworkTopology> parser)\n      throws IOException {\n    try {\n      topology = parser.getNext();\n      if (topology == null) {\n        throw new IOException(\n            \"Input file does not contain valid topology data.\");\n      }\n    } finally {\n      parser.close();\n    }\n  }\n\n  /**\n   * Constructor.\n   * \n   * @param path\n   *          Path to the JSON-encoded topology file, possibly compressed.\n   * @param conf\n   * @throws IOException\n   */\n  public ClusterTopologyReader(Path path, Configuration conf)\n      throws IOException {\n    JsonObjectMapperParser<LoggedNetworkTopology> parser = new JsonObjectMapperParser<LoggedNetworkTopology>(","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-rumen/src/main/java/org/apache/hadoop/tools/rumen/ClusterTopologyReader.java#L20-L56","documentation":"IOException('Input file does not contain valid topology data.') from ClusterTopologyReader.readTopology: the JsonParser's getNext() returned null on the first record, meaning the file had no parseable LoggedNetworkTopology object at its head — either the file is empty or its first JSON value is a different/malformed shape and the mapper could not produce one.","triggerScenarios":"Constructing ClusterTopologyReader (e.g. from Folder with -topology, or directly) pointing at an empty file, a truncated/garbled file, a gz file whose compression ended early, or a trace file (job records) supplied where a topology file was expected.","commonSituations":"Swapping the -topology and trace arguments on the command line; upstream anonymizer/folder runs crashed before writing the file, leaving a 0-byte artifact; CR/LF or BOM mangling; text mode FTP corrupting .gz topology files.","solutions":["Check the file size and head the file — it must start with a JSON object carrying host/rack fields ('{\"name\": ..., \"children\": ...}') not job records","If the file is empty or truncated, regenerate it from the previous pipeline stage (e.g. re-run HadoopLogsAnalyzer -write-topology or the Anonymizer)","Confirm you passed the topology file where a topology is expected, not the job trace","Verify integrity if compressed: gunzip -t file.json.gz"],"exampleFix":"# before\nhadoop ... Folder -topology jobtrace.json ...   # wrong input kind\n\n# after - feed the machine-generated topology, not the trace\nhadoop ... Folder - topology: hadoop ... Folder -topology cluster-topology.json ...  # see next line for exact form\n# correct: -topology <topology.json> where topology.json starts with {\"name\":\"...\",\"children\":[...]}","handlingStrategy":"try-catch","validationCode":"// verify head record shape before constructing the reader\ntry (BufferedReader r = new BufferedReader(\n    new InputStreamReader(fs.open(path), StandardCharsets.UTF_8))) {\n  String first = r.readLine();\n  if (first == null || !first.trim().startsWith(\"{\")) {\n    throw new IllegalArgumentException(\"Not a topology JSON file: \" + path);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  new ClusterTopologyReader(conf, topologyInputPath, statePool);\n} catch (IOException e) {\n  if (e.getMessage().contains(\"valid topology\")) {\n    LOG.error(\"Topology file empty/wrong kind: \" + path);\n  }\n}","preventionTips":["Never pass a job trace where a topology file is expected","Check file size > 0 and head the first JSON object before the run","Regenerate topology files if the producing stage crashed"],"tags":["hadoop","rumen","json-parsing","topology","empty-file"],"backgroundTag":"empty-or-malformed-input-file","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}