{"record":{"id":"e7834efb5841381d","repo":"alibaba/spring-ai-alibaba","slug":"elementclasstype-is-required","errorCode":null,"errorMessage":"ElementClassType is required","messagePattern":"ElementClassType is required","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-boot-starters/spring-ai-alibaba-starter-builtin-nodes/src/main/java/com/alibaba/cloud/ai/graph/node/ListOperatorNode.java","lineNumber":196,"sourceCode":"\n\t\tpublic Builder<T> limitNumber(Long limitNumber) {\n\t\t\tthis.limitNumber = limitNumber;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic Builder<T> limitNumber(Integer limitNumber) {\n\t\t\tthis.limitNumber = Long.valueOf(limitNumber);\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic Builder<T> elementClassType(Class<T> type) {\n\t\t\tthis.type = type;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic ListOperatorNode<T> build() {\n\t\t\tif (type == null && mode == Mode.JSON_STR) {\n\t\t\t\tthrow new IllegalArgumentException(\"ElementClassType is required\");\n\t\t\t}\n\t\t\t// Merge List<Predicate> and List<Comparator> into a single Predicate and a\n\t\t\t// single Comparator, respectively.\n\t\t\treturn new ListOperatorNode<T>(mode, inputKey, outputKey,\n\t\t\t\t\tfilters.stream().reduce(Predicate::and).orElse(t -> true),\n\t\t\t\t\tcomparators.stream().reduce(Comparator::thenComparing).orElse((a, b) -> 0), limitNumber, type);\n\t\t}\n\n\t}\n\n\tpublic static <T> Builder<T> builder() {\n\t\treturn new Builder<T>();\n\t}\n\n}\n","sourceCodeStart":178,"sourceCodeEnd":212,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-boot-starters/spring-ai-alibaba-starter-builtin-nodes/src/main/java/com/alibaba/cloud/ai/graph/node/ListOperatorNode.java#L178-L212","documentation":"ListOperatorNode's Builder.build() throws IllegalArgumentException when the node mode is Mode.JSON_STR but no element ClassType was provided via type(...). In JSON_STR mode the node must know the target element class to deserialize each JSON element, so a missing type makes the node unusable. This is a builder-time validation guard, thrown immediately at graph construction.","triggerScenarios":"Calling ListOperatorNode.Builder with mode(Mode.JSON_STR) (or leaving the default mode) and never calling type(SomeClass.class) before build().","commonSituations":"Copy-pasting a builder example that only sets filters/comparator/limit; switching to JSON_STR mode later and forgetting that type is mandatory in that mode; misreading type(...) as optional for all modes.","solutions":["Call .type(YourElementClass.class) on the builder before build()","If you don't need JSON deserialization to a typed element, switch the builder to a non-JSON_STR mode (e.g. Mode.LIST)","Inspect the builder chain to confirm mode was intentionally set to JSON_STR"],"exampleFix":"// before\nnew ListOperatorNode.Builder<String>(Mode.JSON_STR)\n    .inputKey(\"items\").outputKey(\"result\")\n    .build();\n// after\nnew ListOperatorNode.Builder<String>(Mode.JSON_STR)\n    .inputKey(\"items\").outputKey(\"result\")\n    .type(String.class)\n    .build();","handlingStrategy":"validation","validationCode":"if (mode == ListOperatorNode.Mode.JSON_STR && elementType == null) {\n    throw new IllegalStateException(\"type(...) must be set for Mode.JSON_STR\");\n}","typeGuard":"boolean isJsonModeWith_type(ListOperatorNode.Builder<?> b) { return builderMode == ListOperatorNode.Mode.JSON_STR && elementType != null; }","tryCatchPattern":"try { node = builder.build(); } catch (IllegalArgumentException e) { /* add .type(...) and rebuild */ }","preventionTips":["Always pair Mode.JSON_STR with .type(Class) in your builder helper","Centralize node construction in a factory that enforces mode/type consistency","Review builder chains in code review for mandatory fields"],"tags":["builder-validation","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}