{"record":{"id":"e9a272b12b09ddc8","repo":"alibaba/spring-ai-alibaba","slug":"maxconcurrency-must-be-at-least-1-but-got-e9a272","errorCode":null,"errorMessage":"maxConcurrency must be at least 1, but got: ","messagePattern":"maxConcurrency must be at least 1, but got: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/flow/strategy/ParallelGraphBuildingStrategy.java","lineNumber":169,"sourceCode":"\tprivate void validateParallelConfig(FlowGraphBuilder.FlowGraphConfig config) {\n\t\tif (config.getSubAgents() == null || config.getSubAgents().isEmpty()) {\n\t\t\tthrow new IllegalArgumentException(\"Parallel flow requires at least one sub-agent\");\n\t\t}\n\n\t\tif (config.getSubAgents().size() < 2) {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\"Parallel flow requires at least 2 sub-agents for meaningful parallel execution\");\n\t\t}\n\n\t\t// Ensure root agent is a FlowAgent for input key access\n\t\tif (!(config.getRootAgent() instanceof FlowAgent)) {\n\t\t\tthrow new IllegalArgumentException(\"Parallel flow requires root agent to be a FlowAgent\");\n\t\t}\n\n\t\t// Validate maxConcurrency if provided\n\t\tInteger maxConcurrency = (Integer) config.getCustomProperty(\"maxConcurrency\");\n\t\tif (maxConcurrency != null && maxConcurrency < 1) {\n\t\t\tthrow new IllegalArgumentException(\"maxConcurrency must be at least 1, but got: \" + maxConcurrency);\n\t\t}\n\t}\n\n}\n","sourceCodeStart":151,"sourceCodeEnd":174,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/flow/strategy/ParallelGraphBuildingStrategy.java#L151-L174","documentation":"validateParallelConfig in ParallelGraphBuildingStrategy rejects FlowGraphConfig whose maxConcurrency is below 1 — the parallel execution pool would have no capacity, so the configuration is invalid before graph building.","triggerScenarios":"config.customProperty(\"maxConcurrency\", 0) or a negative/invalid value computed at runtime, passed to a ParallelAgent/FlowGraphBuilder config, then validateParallelConfig runs.","commonSituations":"Computing concurrency from a config file or env var that parses to 0 or -1; defaulting an unset variable to 0; typo passing wrong variable.","solutions":["Set maxConcurrency to a positive integer (>= 1)","Omit the maxConcurrency property entirely to use the default","Validate the source value (config file/env) before assigning it"],"exampleFix":"// before\nbuilder.customProperty(\"maxConcurrency\", 0);\n// after\nbuilder.customProperty(\"maxConcurrency\", Math.max(1, requestedConcurrency));","handlingStrategy":"validation","validationCode":"Integer mc = (Integer) config.getCustomProperty(\"maxConcurrency\");\nif (mc != null && mc < 1) {\n    throw new IllegalArgumentException(\"maxConcurrency must be >= 1, got: \" + mc);\n}","typeGuard":"static Integer sanitizeConcurrency(Integer mc) { return (mc == null || mc < 1) ? null : mc; }","tryCatchPattern":null,"preventionTips":["Clamp user/config-supplied concurrency with Math.max(1, value)","Omit maxConcurrency when unknown instead of defaulting to 0","Validate config-file values at load time"],"tags":["java","agent-framework","validation","configuration"],"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-14T05:17:10.506Z"}