apache/hadoop · error · IOException

input key is null

Error message

input key is null

What it means

Error "input key is null" thrown in apache/hadoop.

Source

Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/main/java/org/apache/hadoop/mapred/nativetask/util/SizedWritable.java:46

public class SizedWritable<T> {
  public static final int INVALID_LENGTH = -1;

  public int length = INVALID_LENGTH;
  public Writable v;

  public SizedWritable(Class<?> klass) {
    if (null != klass) {
      v = (Writable) ReflectionUtils.newInstance(klass, null);
    }
    length = INVALID_LENGTH;
  }

  public void readFields(DataInputBuffer key) throws IOException {
    if (null != key) {
      this.v.readFields(key);
      this.length = INVALID_LENGTH;
    } else {
      throw new IOException("input key is null");
    }

  }

  public void reset(T w) {
    this.v = (Writable) w;
    this.length = INVALID_LENGTH;
  }
}

View on GitHub (pinned to 2add963021)

Solutions

  1. Set the key on SizedWritable before serializing; ensure map output keys are never null.
  2. Guard the mapper output so context.write() is never called with a null key.

When it happens

Trigger: Thrown by SizedWritable constructor when a null key Writable is passed in. nativetask requires non-null keys; filter out null keys before writing to the native collector.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/29fdeebeb35a8f47. Report an issue: GitHub.