{"record":{"id":"3464aba7bd3c4010","repo":"alibaba/spring-ai-alibaba","slug":"redisson-cannot-be-null","errorCode":null,"errorMessage":"redisson cannot be null","messagePattern":"redisson cannot be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/checkpoint/savers/redis/RedisSaver.java","lineNumber":488,"sourceCode":"\t\t\tif (ttlUnit == null) {\n\t\t\t\tthrow new IllegalArgumentException(\"ttlUnit cannot be null\");\n\t\t\t}\n\t\t\tif (ttl == 0 || ttl < -1) {\n\t\t\t\tthrow new IllegalArgumentException(\"ttl must be positive or -1 (no expiration), got: \" + ttl);\n\t\t\t}\n\t\t\tthis.ttl = ttl;\n\t\t\tthis.ttlUnit = ttlUnit;\n\t\t\treturn this;\n\t\t}\n\n\t\t/**\n\t\t * Builds a new RedisSaver instance.\n\t\t * @return a new RedisSaver instance\n\t\t * @throws IllegalArgumentException if redisson or stateSerializer is null\n\t\t */\n\t\tpublic RedisSaver build() {\n\t\t\tif (redisson == null) {\n\t\t\t\tthrow new IllegalArgumentException(\"redisson cannot be null\");\n\t\t\t}\n\t\t\tif (stateSerializer == null) {\n\t\t\t\tthis.stateSerializer = StateGraph.DEFAULT_JACKSON_SERIALIZER;\n\t\t\t}\n\t\t\treturn new RedisSaver(redisson, stateSerializer, ttl, ttlUnit);\n\t\t}\n\t}\n\n}\n","sourceCodeStart":470,"sourceCodeEnd":498,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/checkpoint/savers/redis/RedisSaver.java#L470-L498","documentation":"RedisSaver.Builder.build() requires a RedissonClient; without one there is no Redis connection to persist checkpoints to. Calling build() before calling the builder's redisson(...) setter throws IllegalArgumentException. A null stateSerializer is tolerated and defaults to StateGraph.DEFAULT_JACKSON_SERIALIZER, but redisson is mandatory.","triggerScenarios":"new RedisSaver.Builder().stateSerializer(s).build() without .redisson(redissonClient); conditionally wired bean where the RedissonClient dependency is null (e.g. Redis starter not configured); ordering issue where build() runs before the client is injected.","commonSituations":"Spring configuration missing the Redisson client bean; forgetting to add the redisson dependency/starter; instantiating RedisSaver in unit tests without a (possibly mocked) RedissonClient; profile-based config where redisson bean is not created in the active profile.","solutions":["Create and pass a RedissonClient: new RedisSaver.Builder().redisson(redissonClient).build().","Verify the Redisson client bean exists and is injected (check @Bean definition / spring-boot-starter for redisson).","If redisson may be absent, fail fast at startup with a clear message instead of building the saver conditionally."],"exampleFix":"// before\nRedisSaver saver = new RedisSaver.Builder().build();\n// after\nRedisSaver saver = new RedisSaver.Builder()\n    .redisson(Redisson.create(config))\n    .build();","handlingStrategy":"validation","validationCode":"RedissonClient client = applicationContext.getBean(RedissonClient.class); // fails fast if missing\nRedisSaver saver = new RedisSaver.Builder().redisson(client).build();","typeGuard":null,"tryCatchPattern":"try {\n    saver = new RedisSaver.Builder().redisson(client).build();\n} catch (IllegalArgumentException e) {\n    throw new BeanInitializationException(\"RedisSaver requires a RedissonClient bean; check redisson config\", e);\n}","preventionTips":["Always call .redisson(...) before .build() in the builder chain.","Declare RedissonClient as a required constructor dependency so Spring fails at startup if absent.","Add a startup smoke test that builds the saver in the active profile."],"tags":["redis","builder","redisson","validation"],"backgroundTag":"missing-required-argument","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"}