nathanmarz/storm · error · IllegalArgumentException

Each element of the list

Error message

Each element of the list ${name} must be a ${cls.getName()}.

What it means

ConfigValidation's fieldValidators iterate an Iterable-typed config field and check each element with cls.isInstance(e). If any element is not an instance of the expected class, validateField throws this IllegalArgumentException. It exists to fail fast on misconfigured lists in the Storm config.

Solutions

  1. Find the offending element and convert it to the required class (e.g. use integers not quoted strings for numeric list entries).
  2. Check the config key's expected type in the Storm docs/conf defaults and make every element match.
  3. If building conf in code, wrap element construction with the correct types before putting the list into the Map.
  4. Re-check YAML parsing settings that might coerce numbers to strings.

Example fix

// before
conf.put(Config.NIMBUS_SEEDS, Arrays.asList("nimbus1", "nimbus2")); // validator expects InetAddress/HostPort entries
// after
conf.put(Config.NIMBUS_SEEDS, Arrays.asList("nimbus1", "nimbus2")); // use validator matching element type
// or fix element type:
conf.put(Config.SUPERVISOR_SLOTS_PORTS, Arrays.asList(6700, 6701)); // integers, not "6700"
Defensive patterns

Strategy: validation

Validate before calling

// Java: check list elements before submitting conf
List<?> list = (List<?>) conf.get(key);
for (Object e : list) {
    if (e == null || !expectedClass.isInstance(e)) {
        throw new IllegalStateException(key + " has non-" + expectedClass.getSimpleName() + " element: " + e);
    }
}

Type guard

boolean isListOf(Object v, Class<?> cls) {
    return v instanceof Iterable && Iterables.all((Iterable<?>) v, e -> cls.isInstance(e));
}

Prevention

When it happens

Trigger: Calling a ConfigValidation.validateField-based validator (e.g. FieldListValidator) on a config field declared as a list where at least one element has the wrong runtime type, e.g. a list of Strings passed to a validator expecting Integer elements.

Common situations: Hand-editing storm.yaml or building a conf Map programmatically with mixed-type list entries (e.g. "1" instead of 1); YAML parsers reading numbers as strings; passing the wrong list to the wrong validator key.

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/116b5dbb57d717e2. Report an issue: GitHub.

Appendix: source

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

    /**
     * Returns a new FieldValidator for a List of the given Class.
     * @param cls the Class of elements composing the list
     * @return a FieldValidator for a list of the given class
     */
    static FieldValidator FieldListValidatorFactory(final Class cls) {
        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);

    /**

View on GitHub (pinned to cdb116e942)