{"record":{"id":"eddc332b047cc69e","repo":"alibaba/spring-ai-alibaba","slug":"initialdelay-must-be-greater-than-or-equal-to-0","errorCode":null,"errorMessage":"initialDelay must be greater than or equal to 0.","messagePattern":"initialDelay 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":312,"sourceCode":"\t\t/**\n\t\t * Set the maximum number of retries (including the first call).\n\t\t * @param maxAttempts The maximum number of attempts must be >= 1.\n\t\t */\n\t\tpublic Builder maxAttempts(int maxAttempts) {\n\t\t\tif (maxAttempts < 1) {\n\t\t\t\tthrow new IllegalArgumentException(\"maxAttempts must be greater than or equal to 1\");\n\t\t\t}\n\t\t\tthis.maxAttempts = maxAttempts;\n\t\t\treturn this;\n\t\t}\n\n\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/**","sourceCodeStart":294,"sourceCodeEnd":330,"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#L294-L330","documentation":"ModelRetryInterceptor.Builder.initialDelay(long) validates that the initial backoff delay in milliseconds is non-negative. A negative value throws IllegalArgumentException during building, since a negative sleep/delay is meaningless.","triggerScenarios":"Calling ModelRetryInterceptor.builder().initialDelay(negativeLong) — usually from a mis-signed config value, a subtraction-derived duration, or a typo like initialDelay(-1) intending 'no delay'.","commonSituations":"Configuring delays via properties/env where a negative value slipped in; computing initialDelay from a Duration with an overflow/sign error; copying a template and editing values incorrectly; intending zero delay but passing -1.","solutions":["Pass 0 or a positive millisecond value; use 0 to disable the wait between retries.","Clamp configuration: Math.max(0, configuredInitialDelay).","Parse durations with proper types (Duration.ofMillis) rather than raw signed arithmetic."],"exampleFix":"// before\nretryBuilder.initialDelay(cfg.retryDelayMs()); // -1 when unset\n// after\nretryBuilder.initialDelay(Math.max(0, cfg.retryDelayMs() > 0 ? cfg.retryDelayMs() : 0));","handlingStrategy":"validation","validationCode":"public static ModelRetryInterceptor buildRetry(long initialDelayMs) {\n    if (initialDelayMs < 0) throw new IllegalArgumentException(\"initialDelay must be >= 0 ms\");\n    return ModelRetryInterceptor.builder().initialDelay(initialDelayMs).build();\n}","typeGuard":null,"tryCatchPattern":"try {\n    builder.initialDelay(cfg.initialDelayMs());\n} catch (IllegalArgumentException e) {\n    log.warn(\"Invalid initialDelay ({} ms), defaulting to 1000 ms\", cfg.initialDelayMs());\n    builder.initialDelay(1000);\n}","preventionTips":["Use 0 (not -1) to express 'no delay between retries'.","Parse durations via Duration.toMillis() instead of hand-computed signed values.","Clamp config-derived delays with Math.max(0, value) at the configuration boundary."],"tags":["builder","validation","configuration","backoff"],"backgroundTag":"invalid-argument-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"}