{"record":{"id":"5f30dd02a24340c6","repo":"apache/hadoop","slug":"rec-negative-key-length","errorCode":null,"errorMessage":"Rec# {}: Negative key-length: {}","messagePattern":"Rec# (.+?): Negative key-length: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/IFile.java","lineNumber":409,"sourceCode":"      if (eof) {\n        throw new EOFException(\"Completed reading \" + bytesRead);\n      }\n      \n      // Read key and value lengths\n      currentKeyLength = WritableUtils.readVInt(dIn);\n      currentValueLength = WritableUtils.readVInt(dIn);\n      bytesRead += (long) WritableUtils.getVIntSize(currentKeyLength) +\n                   WritableUtils.getVIntSize(currentValueLength);\n      \n      // Check for EOF\n      if (currentKeyLength == EOF_MARKER && currentValueLength == EOF_MARKER) {\n        eof = true;\n        return false;\n      }\n      \n      // Sanity check\n      if (currentKeyLength < 0) {\n        throw new IOException(\"Rec# \" + recNo + \": Negative key-length: \" + \n                              currentKeyLength);\n      }\n      if (currentValueLength < 0) {\n        throw new IOException(\"Rec# \" + recNo + \": Negative value-length: \" + \n                              currentValueLength);\n      }\n            \n      return true;\n    }\n    \n    public boolean nextRawKey(DataInputBuffer key) throws IOException {\n      if (!positionToNextRecord(dataIn)) {\n        return false;\n      }\n      if (keyBytes.length < currentKeyLength) {\n        keyBytes = new byte[currentKeyLength << 1];\n      }\n      int i = readData(keyBytes, 0, currentKeyLength);","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/IFile.java#L391-L427","documentation":"Error \"Rec# {}: Negative key-length: {}\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/IFile.java:409 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The spill file is corrupt; rerun the failed map task so the framework regenerates the spill, and investigate disk or memory errors on the node that wrote it."],"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-23T01:17:44.959Z"}