{"record":{"id":"4642537e2fdc41a9","repo":"alibaba/spring-ai-alibaba","slug":"model-must-be-specified","errorCode":null,"errorMessage":"model must be specified","messagePattern":"model must be specified","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/hook/summarization/SummarizationHook.java","lineNumber":361,"sourceCode":"\n\t\tpublic Builder summaryPrefix(String prefix) {\n\t\t\tthis.summaryPrefix = prefix;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic Builder tokenCounter(TokenCounter counter) {\n\t\t\tthis.tokenCounter = counter;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic Builder keepFirstUserMessage(boolean keep) {\n\t\t\tthis.keepFirstUserMessage = keep;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic SummarizationHook build() {\n\t\t\tif (model == null) {\n\t\t\t\tthrow new IllegalArgumentException(\"model must be specified\");\n\t\t\t}\n\t\t\treturn new SummarizationHook(this);\n\t\t}\n\t}\n}\n","sourceCodeStart":343,"sourceCodeEnd":367,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/hook/summarization/SummarizationHook.java#L343-L367","documentation":"SummarizationHook.Builder.build() requires a ChatModel: the hook needs it to generate conversation summaries. Building without a model throws this IllegalArgumentException, since summarization cannot function without an LLM.","triggerScenarios":"Calling SummarizationHook.builder()...build() without calling .model(chatModel), or passing null to .model(...).","commonSituations":"In tests where no real model is wired and the builder call was dropped; refactors where the ChatModel bean became optional; copying example code and skipping the model line.","solutions":["Provide a ChatModel: SummarizationHook.builder().model(chatModel).build().","In tests, use a mock/stub ChatModel implementation if real inference is unnecessary.","Guard hook construction so it is only attempted when a ChatModel bean is present."],"exampleFix":"// before\nSummarizationHook hook = SummarizationHook.builder().build();\n// after\nSummarizationHook hook = SummarizationHook.builder()\n    .model(chatModel)\n    .build();","handlingStrategy":"validation","validationCode":"if (chatModel == null) { throw new IllegalStateException(\"ChatModel required for SummarizationHook\"); }\nSummarizationHook hook = SummarizationHook.builder().model(chatModel).build();","typeGuard":"boolean canBuild(Model m) { return m != null; }","tryCatchPattern":"try { hook = builder.model(chatModel).build(); } catch (IllegalArgumentException e) { log.error(\"Summarization unavailable: {}\", e.getMessage()); }","preventionTips":["Provide the ChatModel in the same configuration block that builds the hook.","In tests, supply a stub ChatModel rather than omitting it.","Keep builder calls together so no required setter is skipped."],"tags":["java","builder-validation","llm"],"backgroundTag":"missing-required-option","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}