alibaba/spring-ai-alibaba · error · IllegalArgumentException

redisson cannot be null

Error message

redisson cannot be null

What it means

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.

Source

Thrown at spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/checkpoint/savers/redis/RedisSaver.java:488

			if (ttlUnit == null) {
				throw new IllegalArgumentException("ttlUnit cannot be null");
			}
			if (ttl == 0 || ttl < -1) {
				throw new IllegalArgumentException("ttl must be positive or -1 (no expiration), got: " + ttl);
			}
			this.ttl = ttl;
			this.ttlUnit = ttlUnit;
			return this;
		}

		/**
		 * Builds a new RedisSaver instance.
		 * @return a new RedisSaver instance
		 * @throws IllegalArgumentException if redisson or stateSerializer is null
		 */
		public RedisSaver build() {
			if (redisson == null) {
				throw new IllegalArgumentException("redisson cannot be null");
			}
			if (stateSerializer == null) {
				this.stateSerializer = StateGraph.DEFAULT_JACKSON_SERIALIZER;
			}
			return new RedisSaver(redisson, stateSerializer, ttl, ttlUnit);
		}
	}

}

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Create and pass a RedissonClient: new RedisSaver.Builder().redisson(redissonClient).build().
  2. Verify the Redisson client bean exists and is injected (check @Bean definition / spring-boot-starter for redisson).
  3. If redisson may be absent, fail fast at startup with a clear message instead of building the saver conditionally.

Example fix

// before
RedisSaver saver = new RedisSaver.Builder().build();
// after
RedisSaver saver = new RedisSaver.Builder()
    .redisson(Redisson.create(config))
    .build();
Defensive patterns

Strategy: validation

Validate before calling

RedissonClient client = applicationContext.getBean(RedissonClient.class); // fails fast if missing
RedisSaver saver = new RedisSaver.Builder().redisson(client).build();

Try / catch

try {
    saver = new RedisSaver.Builder().redisson(client).build();
} catch (IllegalArgumentException e) {
    throw new BeanInitializationException("RedisSaver requires a RedissonClient bean; check redisson config", e);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09). Data as JSON: /api/errors/3464aba7bd3c4010. Report an issue: GitHub.