{"record":{"id":"f1e0cdc6d4e0dbc6","repo":"alibaba/spring-cloud-alibaba","slug":"redisdatasource-rulekey-can-not-be-empty","errorCode":null,"errorMessage":"RedisDataSource  ruleKey can not be empty","messagePattern":"RedisDataSource  ruleKey can not be empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-cloud-alibaba-starters/spring-cloud-alibaba-sentinel-datasource/src/main/java/com/alibaba/cloud/sentinel/datasource/config/RedisDataSourceProperties.java","lineNumber":88,"sourceCode":"\t * data key in Redis.\n\t */\n\tprivate @Nullable String ruleKey;\n\n\t/**\n\t * channel to subscribe in Redis.\n\t */\n\tprivate @Nullable String channel;\n\n\t/**\n\t * redis sentinel model.\n\t */\n\tprivate @Nullable String masterId;\n\n\t@Override\n\tpublic void preCheck(String dataSourceName) {\n\t\tsuper.preCheck(dataSourceName);\n\t\tif (StringUtils.isEmpty(ruleKey)) {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\"RedisDataSource  ruleKey can not be empty\");\n\t\t}\n\n\t\tif (StringUtils.isEmpty(channel)) {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\"RedisDataSource  channel can not be empty\");\n\t\t}\n\n\t\tif (StringUtils.isEmpty(masterId)) {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\"RedisDataSource  sentinel model，masterId can not be empty\");\n\t\t}\n\t}\n\n\tpublic String getHost() {\n\t\treturn host;\n\t}\n","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/alibaba/spring-cloud-alibaba/blob/115d5901102009492e05d5ec18c3f79cad4077d0/spring-cloud-alibaba-starters/spring-cloud-alibaba-sentinel-datasource/src/main/java/com/alibaba/cloud/sentinel/datasource/config/RedisDataSourceProperties.java#L70-L106","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add spring.cloud.sentinel.datasource.<name>.redis.ruleKey=<redis-key> to your configuration.","Verify the ruleKey matches the actual key in your Redis instance that holds Sentinel rules.","Ensure ruleKey is not an empty string or whitespace-only value."],"exampleFix":"# before (broken — ruleKey missing)\nspring:\n  cloud:\n    sentinel:\n      datasource:\n        ds1:\n          redis:\n            host: redis.local\n            channel: sentinel-channel\n\n# after (fixed)\nspring:\n  cloud:\n    sentinel:\n      datasource:\n        ds1:\n          redis:\n            host: redis.local\n            ruleKey: sentinel:flow-rules\n            channel: sentinel-channel","handlingStrategy":"validation","validationCode":"// Ensure ruleKey is set for redis Sentinel datasource\nString ruleKey = props.getRedis().getRuleKey();\nif (!StringUtils.hasText(ruleKey)) {\n    throw new IllegalArgumentException(\"RedisDataSource ruleKey is required\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set ruleKey, channel, and masterId together when configuring a Redis Sentinel datasource.","Verify the ruleKey exists in Redis before starting the application.","Use a config snippet template that includes all required Redis properties."],"tags":["sentinel","redis","datasource","configuration","validation"],"backgroundTag":null,"analyzedSha":"115d5901102009492e05d5ec18c3f79cad4077d0","analyzedAt":"2026-08-14T04:47:13.900Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}