{"record":{"id":"49080530229bbe71","repo":"alibaba/spring-ai-alibaba","slug":"fieldname-must-be-at-least-minvalue-got","errorCode":null,"errorMessage":"${fieldName} must be at least ${minValue}, got: ${num}","messagePattern":"(.+?) must be at least (.+?), got: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/builder/generator/service/generator/agent/AbstractAgentTypeProvider.java","lineNumber":110,"sourceCode":"\t}\n\n\t/**\n\t * 校验数值字段\n\t * @param value 字段值\n\t * @param fieldName 字段名\n\t * @param minValue 最小值（包含）\n\t * @return 数值\n\t */\n\tprotected int requirePositiveNumber(Object value, String fieldName, int minValue) {\n\t\tif (value == null) {\n\t\t\tthrow new IllegalArgumentException(type() + \" requires '\" + fieldName + \"'\");\n\t\t}\n\t\tif (!(value instanceof Number)) {\n\t\t\tthrow new IllegalArgumentException(fieldName + \" must be a number\");\n\t\t}\n\t\tint num = ((Number) value).intValue();\n\t\tif (num < minValue) {\n\t\t\tthrow new IllegalArgumentException(fieldName + \" must be at least \" + minValue + \", got: \" + num);\n\t\t}\n\t\treturn num;\n\t}\n\n\t/**\n\t * 检查字符串是否为空\n\t */\n\tprotected boolean isBlank(String s) {\n\t\treturn s == null || s.trim().isEmpty();\n\t}\n\n\t/**\n\t * 检查是否有有效的输入键\n\t */\n\tprotected boolean hasValidInputKey(Map<String, Object> root) {\n\t\tString inputKey = (String) root.get(\"input_key\");\n\t\tList<?> inputKeys = (List<?>) root.get(\"input_keys\");\n\t\treturn !isBlank(inputKey) || (inputKeys != null && !inputKeys.isEmpty());","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/builder/generator/service/generator/agent/AbstractAgentTypeProvider.java#L92-L128","documentation":"requirePositiveNumber() throws this when the numeric field is a Number but below the minimum value required by the agent type (e.g. max_iterations must be >= 1). The message shows both the required minimum and the offending value.","triggerScenarios":"((Number) value).intValue() < minValue in requirePositiveNumber(), e.g. passing max_iterations: 0 to a LoopAgent, or a routing/parallel knob set to 0 or negative.","commonSituations":"Setting a loop limit to 0 intending 'unlimited'; a UI defaulting a field to 0; negative values from a buggy computation upstream.","solutions":["Raise the field's value to at least the stated minimum","For a loop agent wanting many iterations, use a positive number like 1 or the intended bound","Fix upstream logic that computes the value so it cannot produce 0 or negatives"],"exampleFix":"// before\n{\"type\": \"loop_agent\", \"name\": \"looper\", \"max_iterations\": 0}\n// after\n{\"type\": \"loop_agent\", \"name\": \"looper\", \"max_iterations\": 3}","handlingStrategy":"validation","validationCode":"int v = ((Number) config.get(\"max_iterations\")).intValue();\nif (v < 1) {\n    throw new IllegalArgumentException(\"max_iterations must be >= 1, got \" + v);\n}","typeGuard":null,"tryCatchPattern":"try {\n    provider.validateDSL(root);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"must be at least\")) {\n        // read the minimum from the message and clamp/auto-fix the field\n    }\n}","preventionTips":["Enforce minimums in the config UI (min attribute on numeric inputs)","Remember 0 is invalid for counts/iterations — use a positive value","Clamp values programmatically before generation"],"tags":["validation","numeric","range"],"backgroundTag":"value-out-of-range","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"}