{"record":{"id":"265d966463999f2f","repo":"quarkusio/quarkus","slug":"yamllistobjecthandler-can-only-be-used-for-fields","errorCode":null,"errorMessage":"YamlListObjectHandler can only be used for fields / methods that are of type 'List<SomeClass>' where 'SomeClass' is an application class","messagePattern":"YamlListObjectHandler can only be used for fields / methods that are of type 'List<SomeClass>' where 'SomeClass' is an application class","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/spring-boot-properties/deployment/src/main/java/io/quarkus/spring/boot/properties/deployment/YamlListObjectHandler.java","lineNumber":219,"sourceCode":"            throw new IllegalArgumentException(\n                    \"The use of interfaces as the generic type of Lists fields / methods is not allowed. Offending field is '\"\n                            + member.name() + \"' of class '\" + member.declaringClass().name().toString() + \"'\");\n        }\n        if (!classInfo.hasNoArgsConstructor()) {\n            throw new IllegalArgumentException(\n                    String.format(\"Class '%s' which is used as %s in class '%s' must have a no-args constructor\", classInfo,\n                            member.phraseUsage(), member.declaringClass().name().toString()));\n        }\n        if (!Modifier.isPublic(classInfo.flags())) {\n            throw new IllegalArgumentException(\n                    String.format(\"Class '%s' which is used as %s in class '%s' must be a public class\", classInfo,\n                            member.phraseUsage(), member.declaringClass().name().toString()));\n        }\n    }\n\n    private ClassInfo validateType(Type type) {\n        if (type.kind() != Type.Kind.PARAMETERIZED_TYPE) {\n            throw new IllegalArgumentException(ILLEGAL_ARGUMENT_MESSAGE);\n        }\n        ParameterizedType parameterizedType = (ParameterizedType) type;\n        if (!DotNames.LIST.equals(parameterizedType.name())) {\n            throw new IllegalArgumentException(ILLEGAL_ARGUMENT_MESSAGE);\n        }\n        if (parameterizedType.arguments().size() != 1) {\n            throw new IllegalArgumentException(ILLEGAL_ARGUMENT_MESSAGE);\n        }\n        ClassInfo classInfo = index.getClassByName(parameterizedType.arguments().get(0).name());\n        if (classInfo == null) {\n            throw new IllegalArgumentException(ILLEGAL_ARGUMENT_MESSAGE);\n        }\n        return classInfo;\n    }\n\n    /**\n     * An abstraction over Field and Method which we will use in order to keep the same code for Class and Interface cases\n     */","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/spring-boot-properties/deployment/src/main/java/io/quarkus/spring/boot/properties/deployment/YamlListObjectHandler.java#L201-L237","documentation":"validateType only accepts parameterized types named java.util.List; the handler exists solely to bind YAML lists of objects. Any other kind (raw type, array, Map, Optional...) is rejected with IllegalArgumentException.","triggerScenarios":"YamlListObjectHandler.handle is invoked for a member whose type is not a PARAMETERIZED_TYPE (e.g. raw List without type argument, or Set/Map of objects) — typically reached when list-of-object support is misapplied to a non-List member.","commonSituations":"Using Set<SomeClass> or Map<String,SomeClass> for nested config objects and expecting the YAML list handler to support it; raw List fields.","solutions":["Change the member type to List<SomeClass> with an explicit type argument","Use Set<SomeClass>/Map only via @ConfigMapping in quarkus-config-yaml, not via @ConfigProperties class processing","Flatten the structure to supported List-of-object shape"],"exampleFix":"// before\nSet<ServerConfig> servers();\n// after\nList<ServerConfig> servers();","handlingStrategy":"type-guard","validationCode":"static void requireListMember(Field f) {\n    if (!(f.getGenericType() instanceof ParameterizedType p) || p.getRawType() != List.class)\n        throw new IllegalStateException(f + \" must be List<SomeClass>\");\n}","typeGuard":"boolean isListOfObjects(Type t) {\n    return t instanceof ParameterizedType p && p.getRawType() == List.class && p.getActualTypeArguments().length == 1;\n}","tryCatchPattern":"catch (IllegalArgumentException e) { if (e.getMessage().contains(\"List<SomeClass>\")) { /* change member type to List<...> */ } throw e; }","preventionTips":["Declare nested config collections as List<ConcreteClass> only","Avoid Set/Map for class-of-object config under @ConfigProperties processing"],"tags":["quarkus","yaml","config","type-mismatch"],"backgroundTag":"config-type-not-list-of-object","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}