{"record":{"id":"116b5dbb57d717e2","repo":"nathanmarz/storm","slug":"each-element-of-the-list-name-must-be-a-cls-getname","errorCode":null,"errorMessage":"Each element of the list ${name} must be a ${cls.getName()}.","messagePattern":"Each element of the list (.+?) must be a (.+?)\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"storm-core/src/jvm/backtype/storm/ConfigValidation.java","lineNumber":56,"sourceCode":"\n    /**\n     * Returns a new FieldValidator for a List of the given Class.\n     * @param cls the Class of elements composing the list\n     * @return a FieldValidator for a list of the given class\n     */\n    static FieldValidator FieldListValidatorFactory(final Class cls) {\n        return new FieldValidator() {\n            @Override\n            public void validateField(String name, Object field)\n                    throws IllegalArgumentException {\n                if (field == null) {\n                    // A null value is acceptable.\n                    return;\n                }\n                if (field instanceof Iterable) {\n                    for (Object e : (Iterable)field) {\n                        if (! cls.isInstance(e)) {\n                            throw new IllegalArgumentException(\n                                    \"Each element of the list \" + name + \" must be a \" +\n                                    cls.getName() + \".\");\n                        }\n                    }\n                    return;\n                }\n                throw new IllegalArgumentException(\n                        \"Field \" + name + \" must be an Iterable of \" + cls.getName());\n            }\n        };\n    }\n\n    /**\n     * Validates a list of Numbers.\n     */\n    public static Object NumbersValidator = FieldListValidatorFactory(Number.class);\n\n    /**","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/nathanmarz/storm/blob/cdb116e942666973bc4eaa0df098d5bab82739e7/storm-core/src/jvm/backtype/storm/ConfigValidation.java#L38-L74","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Find the offending element and convert it to the required class (e.g. use integers not quoted strings for numeric list entries).","Check the config key's expected type in the Storm docs/conf defaults and make every element match.","If building conf in code, wrap element construction with the correct types before putting the list into the Map.","Re-check YAML parsing settings that might coerce numbers to strings."],"exampleFix":"// before\nconf.put(Config.NIMBUS_SEEDS, Arrays.asList(\"nimbus1\", \"nimbus2\")); // validator expects InetAddress/HostPort entries\n// after\nconf.put(Config.NIMBUS_SEEDS, Arrays.asList(\"nimbus1\", \"nimbus2\")); // use validator matching element type\n// or fix element type:\nconf.put(Config.SUPERVISOR_SLOTS_PORTS, Arrays.asList(6700, 6701)); // integers, not \"6700\"","handlingStrategy":"validation","validationCode":"// Java: check list elements before submitting conf\nList<?> list = (List<?>) conf.get(key);\nfor (Object e : list) {\n    if (e == null || !expectedClass.isInstance(e)) {\n        throw new IllegalStateException(key + \" has non-\" + expectedClass.getSimpleName() + \" element: \" + e);\n    }\n}","typeGuard":"boolean isListOf(Object v, Class<?> cls) {\n    return v instanceof Iterable && Iterables.all((Iterable<?>) v, e -> cls.isInstance(e));\n}","tryCatchPattern":null,"preventionTips":["Use ConfigValidation validators on your own conf before submission.","Avoid quoting numbers in storm.yaml lists.","Keep a unit test that validates your production conf with ConfigValidation."],"tags":["config-validation","type-mismatch","storm"],"backgroundTag":"type-mismatch","analyzedSha":"cdb116e942666973bc4eaa0df098d5bab82739e7","analyzedAt":"2026-09-12T14:30:00.714Z","contentChangedAt":"2026-09-12T14:30:00.714Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}