nathanmarz/storm · error · IllegalArgumentException

Unknown field name:

Error message

Unknown field name: 

What it means

MockTridentTuple (test helper) looks up field values via an index built from the declared fields. getIndex throws IllegalArgumentException when the requested field name is not in the mock tuple's field map.

Solutions

  1. Align the mock tuple's fields with the topology's actual output fields
  2. Fix the field-name typo in the test assertion
  3. Use Testing.parseTuple / completeTopology outputs that carry the real fields

Example fix

// before
MockTridentTuple tuple = new MockTridentTuple(new Fields("a"), Arrays.asList(1));
tuple.getValueByField("b");
// after
MockTridentTuple tuple = new MockTridentTuple(new Fields("a", "b"), Arrays.asList(1, 2));
tuple.getValueByField("b");
Defensive patterns

Strategy: validation

Validate before calling

if (!mockTuple.getFields().contains(fieldName)) {
  // fix fixture: field not declared on mock tuple
}

Try / catch

try {
  Object v = mockTuple.getValueByField("count");
} catch (IllegalArgumentException e) {
  if (e.getMessage().startsWith("Unknown field name")) {
    fail("Test fixture fields do not match topology output: " + e.getMessage());
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling getValueByField("name") on a MockTridentTuple built with a Fields list that doesn't include "name" — usually a typo or fields not registered in the mock's constructor/completeTopology output.

Common situations: Unit-testing Trident topologies where the mock's declared fields diverge from the real topology output; renaming a stream field without updating test fixtures.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at storm-core/src/jvm/storm/trident/testing/MockTridentTuple.java:57

  public MockTridentTuple(List<String> fieldName, Object... values) {
    super(Arrays.asList(values));
    fieldMap = setupFieldMap(fieldName);
  }

  private Map<String, Integer> setupFieldMap(List<String> fieldNames) {
    Map<String, Integer> newFieldMap = new HashMap<String, Integer>(fieldNames.size());

    int idx = 0;
    for (String fieldName : fieldNames) {
      newFieldMap.put(fieldName, idx++);
    }
    return newFieldMap;
  }

  private int getIndex(String fieldName) {
    Integer index = fieldMap.get(fieldName);
    if (index == null) {
      throw new IllegalArgumentException("Unknown field name: " + fieldName);
    }
    return index;
  }

  @Override
  public List<Object> getValues() {
    return this;
  }

  @Override
  public Object getValue(int i) {
    return get(i);
  }

  @Override
  public String getString(int i) {
    return (String)get(i);
  }

View on GitHub (pinned to cdb116e942)