alibaba/spring-cloud-alibaba · error · IllegalArgumentException

RedisDataSource ruleKey can not be empty

Error message

RedisDataSource  ruleKey can not be empty

What it means

Thrown by RedisDataSourceProperties.preCheck when the ruleKey field is null or empty. The ruleKey identifies the Redis key that stores the Sentinel rule data. Note the double space in the original message string ('RedisDataSource ruleKey'). preCheck is called during Sentinel datasource auto-configuration after super.preCheck passes.

Source

Thrown at spring-cloud-alibaba-starters/spring-cloud-alibaba-sentinel-datasource/src/main/java/com/alibaba/cloud/sentinel/datasource/config/RedisDataSourceProperties.java:88

	 * data key in Redis.
	 */
	private @Nullable String ruleKey;

	/**
	 * channel to subscribe in Redis.
	 */
	private @Nullable String channel;

	/**
	 * redis sentinel model.
	 */
	private @Nullable String masterId;

	@Override
	public void preCheck(String dataSourceName) {
		super.preCheck(dataSourceName);
		if (StringUtils.isEmpty(ruleKey)) {
			throw new IllegalArgumentException(
					"RedisDataSource  ruleKey can not be empty");
		}

		if (StringUtils.isEmpty(channel)) {
			throw new IllegalArgumentException(
					"RedisDataSource  channel can not be empty");
		}

		if (StringUtils.isEmpty(masterId)) {
			throw new IllegalArgumentException(
					"RedisDataSource  sentinel model,masterId can not be empty");
		}
	}

	public String getHost() {
		return host;
	}

View on GitHub (pinned to 115d590110)

Solutions

  1. Add spring.cloud.sentinel.datasource.<name>.redis.ruleKey=<redis-key> to your configuration.
  2. Verify the ruleKey matches the actual key in your Redis instance that holds Sentinel rules.
  3. Ensure ruleKey is not an empty string or whitespace-only value.

Example fix

# before (broken — ruleKey missing)
spring:
  cloud:
    sentinel:
      datasource:
        ds1:
          redis:
            host: redis.local
            channel: sentinel-channel

# after (fixed)
spring:
  cloud:
    sentinel:
      datasource:
        ds1:
          redis:
            host: redis.local
            ruleKey: sentinel:flow-rules
            channel: sentinel-channel
Defensive patterns

Strategy: validation

Validate before calling

// Ensure ruleKey is set for redis Sentinel datasource
String ruleKey = props.getRedis().getRuleKey();
if (!StringUtils.hasText(ruleKey)) {
    throw new IllegalArgumentException("RedisDataSource ruleKey is required");
}

Prevention

When it happens

Trigger: Configuring a Sentinel datasource of type 'redis' without the ruleKey property. The ruleKey field is @Nullable with no default, so omitting spring.cloud.sentinel.datasource.<name>.redis.ruleKey triggers this check.

Common situations: 1) Developer sets redis host/port but forgets ruleKey. 2) The Redis key name was changed but application config was not updated. 3) Placeholder variable for the key is not set in the environment.

Related errors


AI-assisted analysis of alibaba/spring-cloud-alibaba@115d590110 (2026-08-14). Data as JSON: /api/errors/f1e0cdc6d4e0dbc6. Report an issue: GitHub.