{"record":{"id":"f1351f1d6360b5a0","repo":"apache/hadoop","slug":"print-network-topology-failed-f1351f","errorCode":null,"errorMessage":"Print network topology failed. {}","messagePattern":"Print network topology failed\\. (.+?)","errorType":"http","errorClass":"IOException","httpStatus":410,"severity":"warning","filePath":"hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterNetworkTopologyServlet.java","lineNumber":76,"sourceCode":"      try {\n        datanodeReport = syncReturn(DatanodeInfo[].class);\n      } catch (Exception e) {\n        throw new IOException(e);\n      }\n    } else {\n      datanodeReport = router.getRpcServer().getDatanodeReport(\n          HdfsConstants.DatanodeReportType.ALL);\n    }\n    List<Node> datanodeInfos = Arrays.asList(datanodeReport);\n\n    try (PrintStream out = new PrintStream(\n            response.getOutputStream(), false, \"UTF-8\")) {\n      printTopology(out, datanodeInfos, format);\n    } catch (Throwable t) {\n      String errMsg = \"Print network topology failed. \"\n              + StringUtils.stringifyException(t);\n      response.sendError(HttpServletResponse.SC_GONE, errMsg);\n      throw new IOException(errMsg);\n    } finally {\n      response.getOutputStream().close();\n    }\n  }\n}","sourceCodeStart":58,"sourceCodeEnd":81,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterNetworkTopologyServlet.java#L58-L81","documentation":"RouterNetworkTopologyServlet serves the /topology endpoint on the router's HTTP (admin) server, printing the network topology of all datanodes. Any Throwable raised while streaming the topology (printTopology) is stringified, reported to the client as HTTP 410 Gone, and rethrown as an IOException from the servlet.","triggerScenarios":"A GET request to the router's /topology endpoint (optionally with a format parameter) where printTopology fails: an unsupported format string, an exception while walking the datanode report (e.g. null/bad Node data), or an output-stream failure after the response started.","commonSituations":"Operators scraping the router UI/topology page for rack layout; a malformed format query parameter; router whose datanode report is in an unexpected state (e.g. resolver returned empty/None layout) causing a NPE inside topology printing.","solutions":["Read the stringified exception in the 410 response body - it contains the original stack trace","Retry the request without the format parameter (or with a supported one) to rule out bad input","Check the router log for the same stack and verify getDatanodeReport works via hdfs dfsadmin -fs router:// -report","If the resolver layout is broken (NPE on node parent/rack), fix the resolver/state store configuration and restart the router"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Health-check the report before scraping the servlet\nDatanodeInfo[] report = routerRpcServer.getDatanodeReport(DatanodeReportType.ALL);\nif (report == null) {  // defensive: servlet dereferences Arrays.asList(report) earlier\n  LOG.warn(\"Datanode report unavailable; /topology may fail\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  ResponseEntity<String> resp = restTemplate.getForEntity(routerTopologyUrl, String.class);\n  if (resp.getStatusCode() == HttpStatus.GONE) {  // servlet sends 410 with stringified cause\n    LOG.warn(\"Topology print failed: {}\", resp.getBody());\n    // retry later; inspect router log for the original stack\n  }\n} catch (RestClientException e) {\n  // connection-level failure, distinct from the servlet's 410\n}","preventionTips":["Monitor the router's /topology endpoint with alerting on 410 responses and log the body (it carries the stack)","Pass only supported format parameters; test format handling before automating scrapes","Keep the router RPC server and resolvers healthy - most topology print failures trace to bad resolver state"],"tags":["hdfs","router","federation","http-servlet","topology","monitoring","admin-ui"],"backgroundTag":"http-endpoint-internal-error","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}