{"record":{"id":"7126106fa57e8639","repo":"apache/hadoop","slug":"unknown-key","errorCode":"UNKNOWN_KEY","errorMessage":"Unknown key","messagePattern":"Unknown key","errorType":"exception","errorClass":"DiskBalancerException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java","lineNumber":4319,"sourceCode":"   * example : DiskBalancer bandwidth.\n   *\n   * @param key - String that represents the run time key value.\n   * @return value of the key as a string.\n   * @throws IOException - Throws if there is no such key\n   */\n  @Override\n  public String getDiskBalancerSetting(String key) throws IOException {\n    checkSuperuserPrivilege();\n    Preconditions.checkNotNull(key);\n    switch (key) {\n    case DiskBalancerConstants.DISKBALANCER_VOLUME_NAME:\n      return getDiskBalancer().getVolumeNames();\n    case DiskBalancerConstants.DISKBALANCER_BANDWIDTH :\n      return Long.toString(getDiskBalancer().getBandwidth());\n    default:\n      LOG.error(\"Disk Balancer - Unknown key in get balancer setting. Key: {}\",\n          key);\n      throw new DiskBalancerException(\"Unknown key\",\n          DiskBalancerException.Result.UNKNOWN_KEY);\n    }\n  }\n\n  @VisibleForTesting\n  void setBlockScanner(BlockScanner blockScanner) {\n    this.blockScanner = blockScanner;\n  }\n\n  @Override // DataNodeMXBean\n  public String getSendPacketDownstreamAvgInfo() {\n    return dnConf.peerStatsEnabled && peerMetrics != null ?\n        peerMetrics.dumpSendPacketDownstreamAvgInfoAsJson() : null;\n  }\n\n  @Override // DataNodeMXBean\n  public String getSlowDisks() {\n    if (!dnConf.diskStatsEnabled || diskMetrics == null) {","sourceCodeStart":4301,"sourceCodeEnd":4337,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java#L4301-L4337","documentation":"getDiskBalancerSetting is a small key/value settings RPC that recognizes exactly two keys: DiskBalancerConstants.DISKBALANCER_VOLUME_NAME (volume list) and DISKBALANCER_BANDWIDTH (current bandwidth). Anything else falls through to default, logs the offending key, and raises DiskBalancerException Result.UNKNOWN_KEY.","triggerScenarios":"Calling ClientDatanodeProtocol.getDiskBalancerSetting with any key other than the two supported constants - misspelled key, wrong case, stray whitespace, or an invented setting name.","commonSituations":"Tooling built with hardcoded strings instead of DiskBalancerConstants; clients written against a different Hadoop version; config interpolation inserting whitespace into the key.","solutions":["Use the constants from org.apache.hadoop.hdfs.server.datanode.diskbalancer.DiskBalancerConstants instead of string literals","Trim and normalize the key before sending it","Check the DN log line 'Disk Balancer - Unknown key ... Key: X' to see the exact string that arrived at the server"],"exampleFix":"// before\nString bw = protocol.getDiskBalancerSetting(\"bandwidth \"); // typo + whitespace -> UNKNOWN_KEY\n\n// after\nString bw = protocol.getDiskBalancerSetting(\n    DiskBalancerConstants.DISKBALANCER_BANDWIDTH.trim());","handlingStrategy":"validation","validationCode":"Set<String> allowed = new HashSet<>(Arrays.asList(\n    DiskBalancerConstants.DISKBALANCER_VOLUME_NAME,\n    DiskBalancerConstants.DISKBALANCER_BANDWIDTH));\nif (!allowed.contains(key)) {\n  throw new IllegalArgumentException(\"Unsupported disk balancer setting: \" + key);\n}\nString value = protocol.getDiskBalancerSetting(key);","typeGuard":null,"tryCatchPattern":"catch (DiskBalancerException e) {\n  if (e.getResult() == DiskBalancerException.Result.UNKNOWN_KEY) {\n    // surface which key was rejected; correct and retry\n  } else { throw e; }\n}","preventionTips":["Reference DiskBalancerConstants instead of string literals","Trim/normalize keys before sending them over RPC","Log the exact key sent so the server-side 'Unknown key' line can be matched"],"tags":["hadoop","hdfs","datanode","diskbalancer","configuration","rpc"],"backgroundTag":"unknown-config-key","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}