nathanmarz/storm · error · IllegalArgumentException

Tuple created with wrong number of fields. Expected

Error message

Tuple created with wrong number of fields. Expected ${schema.size()} fields but got ${values.size()} fields

What it means

Thrown in the TupleImpl constructor when the values list length does not match the declared output schema size of the stream the tuple is being created for. Storm validates at tuple-creation time that every tuple conforms to the component's declared fields, so this error indicates an emit call is producing the wrong number of values for the stream.

Solutions

  1. Make the number of values passed to emit match the fields declared for that output stream (e.g. declare(new Fields("a","b")) requires exactly 2 values).
  2. If the tuple shape changed, update the OutputFieldsDeclarer declaration to reflect the new schema.
  3. Check for emitting to the wrong stream, where a different schema size is expected.
  4. Count tuple values dynamically and pad/trim intentionally rather than relying on accidental list lengths.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at storm-core/src/jvm/backtype/storm/tuple/TupleImpl.java:55 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of nathanmarz/storm@cdb116e942 (2026-09-12). Data as JSON: /api/errors/e3bf408fd0425f22. Report an issue: GitHub.

Appendix: source

Thrown at storm-core/src/jvm/backtype/storm/tuple/TupleImpl.java:55

public class TupleImpl extends IndifferentAccessMap implements Seqable, Indexed, IMeta, Tuple {
    private List<Object> values;
    private int taskId;
    private String streamId;
    private GeneralTopologyContext context;
    private MessageId id;
    private IPersistentMap _meta = null;
    
    public TupleImpl(GeneralTopologyContext context, List<Object> values, int taskId, String streamId, MessageId id) {
        this.values = values;
        this.taskId = taskId;
        this.streamId = streamId;
        this.id = id;
        this.context = context;
        
        String componentId = context.getComponentId(taskId);
        Fields schema = context.getComponentOutputFields(componentId, streamId);
        if(values.size()!=schema.size()) {
            throw new IllegalArgumentException(
                    "Tuple created with wrong number of fields. " +
                    "Expected " + schema.size() + " fields but got " +
                    values.size() + " fields");
        }
    }

    public TupleImpl(GeneralTopologyContext context, List<Object> values, int taskId, String streamId) {
        this(context, values, taskId, streamId, MessageId.makeUnanchored());
    }    
    
    Long _processSampleStartTime = null;
    Long _executeSampleStartTime = null;
    
    public void setProcessSampleStartTime(long ms) {
        _processSampleStartTime = ms;
    }

    public Long getProcessSampleStartTime() {

View on GitHub (pinned to cdb116e942)