{"record":{"id":"af8696a0754b61bc","repo":"apache/hadoop","slug":"wrong-key-class-is-not-af8696","errorCode":null,"errorMessage":"wrong key class: {} is not {}","messagePattern":"wrong key class: (.+?) is not (.+?)","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":192,"sourceCode":"      }\n\n      compressedBytesWritten = rawOut.getPos() - start;\n\n      if (compressOutput) {\n        // Return back the compressor\n        CodecPool.returnCompressor(compressor);\n        compressor = null;\n      }\n\n      out = null;\n      if(writtenRecordsCounter != null) {\n        writtenRecordsCounter.increment(numRecordsWritten);\n      }\n    }\n\n    public void append(K key, V value) throws IOException {\n      if (key.getClass() != keyClass)\n        throw new IOException(\"wrong key class: \"+ key.getClass()\n                              +\" is not \"+ keyClass);\n      if (value.getClass() != valueClass)\n        throw new IOException(\"wrong value class: \"+ value.getClass()\n                              +\" is not \"+ valueClass);\n\n      // Append the 'key'\n      keySerializer.serialize(key);\n      int keyLength = buffer.getLength();\n      if (keyLength < 0) {\n        throw new IOException(\"Negative key-length not allowed: \" + keyLength + \n                              \" for \" + key);\n      }\n\n      // Append the 'value'\n      valueSerializer.serialize(value);\n      int valueLength = buffer.getLength() - keyLength;\n      if (valueLength < 0) {\n        throw new IOException(\"Negative value-length not allowed: \" + ","sourceCodeStart":174,"sourceCodeEnd":210,"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#L174-L210","documentation":"Error \"wrong key class: {} is not {}\" 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:192 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Configure the map output key class (mapreduce.map.output.key.class) to match the key class the IFile writer/reader was created with.","Check that the SerializationFactory accepts the configured key class."],"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"}