{"record":{"id":"75997d0d0d4977c9","repo":"apache/hadoop","slug":"found-a-block-string-when-in-state","errorCode":null,"errorMessage":"Found a block string when in state: {}","messagePattern":"Found a block string when in state: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-blockgen/src/main/java/org/apache/hadoop/tools/dynamometer/blockgenerator/XMLParser.java","lineNumber":101,"sourceCode":"      transitionTo(State.INODE);\n    }\n    if (line.contains(\"<type>FILE</type>\")) {\n      transitionTo(State.FILE);\n    }\n    List<String> replicationStrings = valuesFromXMLString(line, \"replication\");\n    if (!replicationStrings.isEmpty()) {\n      if (replicationStrings.size() > 1) {\n        throw new IOException(String.format(\"Found %s replication strings\",\n            replicationStrings.size()));\n      }\n      transitionTo(State.FILE_WITH_REPLICATION);\n      currentReplication = Short.parseShort(replicationStrings.get(0));\n    }\n    Matcher blockMatcher = BLOCK_PATTERN.matcher(line);\n    List<BlockInfo> blockInfos = new ArrayList<>();\n    while (blockMatcher.find()) {\n      if (currentState != State.FILE_WITH_REPLICATION) {\n        throw new IOException(\n            \"Found a block string when in state: \" + currentState);\n      }\n      long id = Long.parseLong(blockMatcher.group(1));\n      long gs = Long.parseLong(blockMatcher.group(2));\n      long size = Long.parseLong(blockMatcher.group(3));\n      blockInfos.add(new BlockInfo(id, gs, size, currentReplication));\n    }\n    if (line.contains(\"</inode>\")) {\n      transitionTo(State.INODE_SECTION);\n    }\n    if (line.contains(\"</INodeSection>\")) {\n      transitionTo(State.DEFAULT);\n    }\n    return blockInfos;\n  }\n\n  /**\n   * Attempt to transition to another state.","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-blockgen/src/main/java/org/apache/hadoop/tools/dynamometer/blockgenerator/XMLParser.java#L83-L119","documentation":"Error \"Found a block string when in state: {}\" thrown in apache/hadoop.","triggerScenarios":"The XMLParser reads a block string token while the parser state machine is in an unexpected state, typically caused by a corrupted or hand-edited fsimage XML file fed to the dynamometer block generator.","commonSituations":"See trigger scenarios.","solutions":["Regenerate the fsimage XML input; the parser hit a block element while in the wrong parser state.","Do not edit the fsimage XML by hand; regenerate it with hdfs oiv."],"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"}