nathanmarz/storm · error · IllegalArgumentException

Field must be an Iterable of

Error message

Field ${name} must be an Iterable of ${cls.getName()}

What it means

After element checks pass, the validator requires the field value itself to be an Iterable. If the value is null-typed as non-iterable or not an Iterable at all, validateField throws this IllegalArgumentException. It is the fallback when the field cannot be validated as a list of the given class.

Solutions

  1. Wrap the value in a list (YAML: `[value]` or block list syntax).
  2. Verify the config key requires a list and you are not confusing it with a scalar key.
  3. If set programmatically, use Arrays.asList(...) / Collections.singletonList(...) for the Map value.

Example fix

// before
conf.put(Config.DRPC_SERVERS, "drpc-host");
// after
conf.put(Config.DRPC_SERVERS, Arrays.asList("drpc-host"));
Defensive patterns

Strategy: validation

Validate before calling

Object v = conf.get(key);
if (!(v instanceof List)) {
    throw new IllegalStateException(key + " must be a list, got: " + (v == null ? "null" : v.getClass().getSimpleName()));
}

Type guard

boolean isList(Object v) { return v instanceof List; }

Prevention

When it happens

Trigger: Passing a non-Iterable value (String, Integer, Map) for a config key validated as a list-of-T, so `field instanceof Iterable` is false and control reaches the final throw.

Common situations: Setting a single value instead of a list in storm.yaml (e.g. `drpc.servers: server1` instead of a YAML list); typo making the value a scalar; programmatic conf Maps with scalars where lists are required.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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

Appendix: source

Thrown at storm-core/src/jvm/backtype/storm/ConfigValidation.java:63

        return new FieldValidator() {
            @Override
            public void validateField(String name, Object field)
                    throws IllegalArgumentException {
                if (field == null) {
                    // A null value is acceptable.
                    return;
                }
                if (field instanceof Iterable) {
                    for (Object e : (Iterable)field) {
                        if (! cls.isInstance(e)) {
                            throw new IllegalArgumentException(
                                    "Each element of the list " + name + " must be a " +
                                    cls.getName() + ".");
                        }
                    }
                    return;
                }
                throw new IllegalArgumentException(
                        "Field " + name + " must be an Iterable of " + cls.getName());
            }
        };
    }

    /**
     * Validates a list of Numbers.
     */
    public static Object NumbersValidator = FieldListValidatorFactory(Number.class);

    /**
     * Validates is a list of Strings.
     */
    public static Object StringsValidator = FieldListValidatorFactory(String.class);

    /**
     * Validates is a list of Maps.
     */

View on GitHub (pinned to cdb116e942)