{"record":{"id":"b6eb0a288c75d9c8","repo":"alibaba/spring-ai-alibaba","slug":"maxdelay-must-be-greater-than-or-equal-to-0","errorCode":null,"errorMessage":"maxDelay must be greater than or equal to 0.","messagePattern":"maxDelay must be greater than or equal to 0\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/interceptor/modelretry/ModelRetryInterceptor.java","lineNumber":324,"sourceCode":"\t\t/**\n\t\t * Set the initial retry delay (milliseconds).\n\t\t * @param initialDelay Initial delay time, in milliseconds\n\t\t */\n\t\tpublic Builder initialDelay(long initialDelay) {\n\t\t\tif (initialDelay < 0) {\n\t\t\t\tthrow new IllegalArgumentException(\"initialDelay must be greater than or equal to 0.\");\n\t\t\t}\n\t\t\tthis.initialDelay = initialDelay;\n\t\t\treturn this;\n\t\t}\n\n\t\t/**\n\t\t * Set the maximum retry delay (milliseconds).\n\t\t * @param maxDelay Maximum delay time, in milliseconds\n\t\t */\n\t\tpublic Builder maxDelay(long maxDelay) {\n\t\t\tif (maxDelay < 0) {\n\t\t\t\tthrow new IllegalArgumentException(\"maxDelay must be greater than or equal to 0.\");\n\t\t\t}\n\t\t\tthis.maxDelay = maxDelay;\n\t\t\treturn this;\n\t\t}\n\n\t\t/**\n\t\t * Set the backoff factor (the multiplier for the delay time on each retry).\n\t\t * @param backoffMultiplier The retreat factor must be >= 1.0\n\t\t */\n\t\tpublic Builder backoffMultiplier(double backoffMultiplier) {\n\t\t\tif (backoffMultiplier < 1.0) {\n\t\t\t\tthrow new IllegalArgumentException(\"The backoffMultiplier must be >= 1.0\");\n\t\t\t}\n\t\t\tthis.backoffMultiplier = backoffMultiplier;\n\t\t\treturn this;\n\t\t}\n\n\t\t/**","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/interceptor/modelretry/ModelRetryInterceptor.java#L306-L342","documentation":"ModelRetryInterceptor's Builder.maxDelay() validates that the configured maximum retry delay is non-negative. A negative value would make retry backoff scheduling meaningless, so the builder rejects it eagerly with IllegalArgumentException. This is a fail-fast guard on configuration, not a runtime failure.","triggerScenarios":"Calling ModelRetryInterceptor.Builder.maxDelay() with a negative long, e.g. maxDelay(-1) or a negative value computed from config/properties.","commonSituations":"Config value read from YAML/properties parsed as negative; arithmetic like baseDelay - increment yielding negative; sign typo when hardcoding.","solutions":["Pass a non-negative maxDelay (>= 0 ms)","Clamp or Math.max(0, configuredValue) before calling maxDelay()","Fix the config source so the delay property is not negative"],"exampleFix":"// before\nnew ModelRetryInterceptor.Builder().maxDelay(-500)\n// after\nnew ModelRetryInterceptor.Builder().maxDelay(5000)","handlingStrategy":"validation","validationCode":"if (configuredMaxDelay < 0) { throw new IllegalArgumentException(\"maxDelay must be >= 0, got \" + configuredMaxDelay); }\ninterceptor = ModelRetryInterceptor.builder().maxDelay(Math.max(0, configuredMaxDelay)).build();","typeGuard":"boolean isValidMaxDelay(long d) { return d >= 0; }","tryCatchPattern":"try { builder.maxDelay(v); } catch (IllegalArgumentException e) { log.warn(\"Bad maxDelay, using default\", e); builder.maxDelay(10_000); }","preventionTips":["Clamp delay config with Math.max(0, value) before applying","Validate delay properties at config load time","Never compute delays via subtraction without a floor"],"tags":["config","retry","validation","illegal-argument"],"backgroundTag":"invalid-config-value","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"}