{"record":{"id":"f891c147c0da279f","repo":"apache/hadoop","slug":"bad-status","errorCode":null,"errorMessage":"Bad status: ","messagePattern":"Bad status: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/PBHelper.java","lineNumber":729,"sourceCode":"\n  public static ReceivedDeletedBlockInfoProto convert(\n      ReceivedDeletedBlockInfo receivedDeletedBlockInfo) {\n    ReceivedDeletedBlockInfoProto.Builder builder = \n        ReceivedDeletedBlockInfoProto.newBuilder();\n    \n    ReceivedDeletedBlockInfoProto.BlockStatus status;\n    switch (receivedDeletedBlockInfo.getStatus()) {\n    case RECEIVING_BLOCK:\n      status = ReceivedDeletedBlockInfoProto.BlockStatus.RECEIVING;\n      break;\n    case RECEIVED_BLOCK:\n      status = ReceivedDeletedBlockInfoProto.BlockStatus.RECEIVED;\n      break;\n    case DELETED_BLOCK:\n      status = ReceivedDeletedBlockInfoProto.BlockStatus.DELETED;\n      break;\n    default:\n      throw new IllegalArgumentException(\"Bad status: \" +\n          receivedDeletedBlockInfo.getStatus());\n    }\n    builder.setStatus(status);\n    \n    if (receivedDeletedBlockInfo.getDelHints() != null) {\n      builder.setDeleteHint(receivedDeletedBlockInfo.getDelHints());\n    }\n    return builder.setBlock(\n        PBHelperClient.convert(receivedDeletedBlockInfo.getBlock())).build();\n  }\n\n  public static ReceivedDeletedBlockInfo convert(\n      ReceivedDeletedBlockInfoProto proto) {\n    ReceivedDeletedBlockInfo.BlockStatus status = null;\n    switch (proto.getStatus()) {\n    case RECEIVING:\n      status = BlockStatus.RECEIVING_BLOCK;\n      break;","sourceCodeStart":711,"sourceCodeEnd":747,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/PBHelper.java#L711-L747","documentation":"PBHelper.convert(ReceivedDeletedBlockInfo) serializes a block-report delta entry (block plus RECEIVING/RECEIVED/DELETED status) between NameNode and Datanode. The switch covers exactly three statuses; anything else reaches the default branch and throws IllegalArgumentException naming the offending status.","triggerScenarios":"receivedDeletedBlockInfo.getStatus() returns a value other than RECEIVING_BLOCK, RECEIVED_BLOCK, DELETED_BLOCK — typically a status constant added in a newer Hadoop release being serialized by an older PBHelper, or custom code constructing ReceivedDeletedBlockInfo with an out-of-range status.","commonSituations":"Version skew during rolling upgrades between NN and DN block-report handling; custom datanode instrumentation that alters status; corrupted in-memory enum (rare).","solutions":["Read the bad status value from the exception message and identify which node produced it.","Align NameNode and Datanode software versions (finish or revert the rolling upgrade).","If custom code builds ReceivedDeletedBlockInfo, restrict status to the three known values.","Upgrade the parsing side to a release that knows the new enum constant."],"exampleFix":"// before\nReceivedDeletedBlockInfo rdbi = new ReceivedDeletedBlockInfo(block, myStatus, hint);\nproto = PBHelper.convert(rdbi); // myStatus may be unknown\n\n// after\nSet<ReceivedDeletedBlockInfo.BlockStatus> known = EnumSet.of(\n    RECEIVING_BLOCK, RECEIVED_BLOCK, DELETED_BLOCK);\nif (!known.contains(myStatus)) {\n  throw new IllegalArgumentException(\"unsupported status: \" + myStatus);\n}","handlingStrategy":"validation","validationCode":"import org.apache.hadoop.hdfs.server.protocol.ReceivedDeletedBlockInfo;\nimport java.util.EnumSet;\n\nEnumSet<ReceivedDeletedBlockInfo.BlockStatus> known = EnumSet.of(\n    ReceivedDeletedBlockInfo.BlockStatus.RECEIVING_BLOCK,\n    ReceivedDeletedBlockInfo.BlockStatus.RECEIVED_BLOCK,\n    ReceivedDeletedBlockInfo.BlockStatus.DELETED_BLOCK);\nif (!known.contains(rdbi.getStatus())) {\n  throw new IllegalArgumentException(\"Unsupported block status: \" + rdbi.getStatus());\n}\n// safe to convert\nproto = PBHelper.convert(rdbi);","typeGuard":"static boolean isKnownBlockStatus(ReceivedDeletedBlockInfo rdbi) {\n  switch (rdbi.getStatus()) {\n    case RECEIVING_BLOCK:\n    case RECEIVED_BLOCK:\n    case DELETED_BLOCK:\n      return true;\n    default:\n      return false;\n  }\n}","tryCatchPattern":"try {\n  builder.setStatus(PBHelper.convert(rdbi));\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Bad status:\")) {\n    // unknown enum from a newer peer: quarantine the entry, alert on version skew\n    LOG.warn(\"Dropping block report entry with unknown status: {}\", rdbi.getStatus());\n    return;\n  }\n  throw e;\n}","preventionTips":["During rolling upgrades, drain old datanodes before adding new ones to block-report paths.","Monitor for IllegalArgumentException with 'Bad status' as an early version-skew detector.","Constrain custom code that constructs ReceivedDeletedBlockInfo to the three documented statuses."],"tags":["hdfs","block-report","protobuf","enum","serialization"],"backgroundTag":"enum-deserialization-unknown-value","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}