{"record":{"id":"572517e6200ab63f","repo":"alibaba/Sentinel","slug":"bad-argument-rulekey-s","errorCode":null,"errorMessage":"Bad argument: ruleKey=[%s]","messagePattern":"Bad argument: ruleKey=\\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sentinel-extension/sentinel-datasource-spring-cloud-config/src/main/java/com/alibaba/csp/sentinel/datasource/spring/cloud/config/SpringCloudConfigDataSource.java","lineNumber":54,"sourceCode":" * </p>\n *\n * @author lianglin\n * @since 1.7.0\n */\npublic class SpringCloudConfigDataSource<T> extends AbstractDataSource<String, T> {\n\n    private final static Map<SpringCloudConfigDataSource, SpringConfigListener> listeners;\n\n    static {\n        listeners = new ConcurrentHashMap<>();\n    }\n\n    private final String ruleKey;\n\n    public SpringCloudConfigDataSource(final String ruleKey, Converter<String, T> converter) {\n        super(converter);\n        if (StringUtil.isBlank(ruleKey)) {\n            throw new IllegalArgumentException(String.format(\"Bad argument: ruleKey=[%s]\", ruleKey));\n        }\n\n        this.ruleKey = ruleKey;\n        loadInitialConfig();\n        initListener();\n    }\n\n    private void loadInitialConfig() {\n        try {\n            T newValue = loadConfig();\n            if (newValue == null) {\n                RecordLog.warn(\"[SpringCloudConfigDataSource] WARN: initial application is null, you may have to check your data source\");\n            }\n            getProperty().updateValue(newValue);\n        } catch (Exception ex) {\n            RecordLog.warn(\"[SpringCloudConfigDataSource] Error when loading initial application\", ex);\n        }\n    }","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/alibaba/Sentinel/blob/a3f40ba8e900c8489bd520274739f17235a7721c/sentinel-extension/sentinel-datasource-spring-cloud-config/src/main/java/com/alibaba/csp/sentinel/datasource/spring/cloud/config/SpringCloudConfigDataSource.java#L36-L72","documentation":"Thrown by the SpringCloudConfigDataSource constructor when ruleKey is blank (null, empty, or whitespace). The ruleKey is the property key under which Sentinel rules are stored in the Spring Cloud Config environment; a blank key cannot identify any rule property, so construction is refused.","triggerScenarios":"new SpringCloudConfigDataSource(ruleKey, converter) with an unresolved placeholder (\"${sentinel.flow-rule.key}\" never substituted), a null property lookup, or an empty string literal.","commonSituations":"The property defining the rule key exists in application.yml but not in the active profile; typo in the property name; Spring placeholder left unresolved because the config file defining it is missing from the classpath.","solutions":["Provide the concrete key that exists in the Config Server environment, e.g. \"my-app.flow.rule\" or the conventional ${spring.application.name}-flow-rules.","Verify the key on the Config Server side (the property must exist there) and in local bootstrap/application config.","Log the resolved ruleKey value before constructing so unresolved placeholders are visible at startup."],"exampleFix":"// before\nnew SpringCloudConfigDataSource<>(env.getProperty(\"sentinel.rule.key\"), converter); // null if unset\n\n// after\nString ruleKey = Objects.requireNonNull(env.getProperty(\"sentinel.rule.key\"),\n    \"sentinel.rule.key must be set\");\nnew SpringCloudConfigDataSource<>(ruleKey, converter);","handlingStrategy":"validation","validationCode":"String ruleKey = env.getProperty(\"sentinel.rule.key\");\nif (StringUtil.isBlank(ruleKey)) {\n    throw new IllegalArgumentException(\"sentinel.rule.key must be set (e.g. my-app-flow-rules)\");\n}\nnew SpringCloudConfigDataSource<>(ruleKey, converter);","typeGuard":null,"tryCatchPattern":"try {\n    new SpringCloudConfigDataSource<>(ruleKey, converter);\n} catch (IllegalArgumentException e) {\n    throw new IllegalStateException(\"SpringCloudConfigDataSource ruleKey not configured\", e);\n}","preventionTips":["Define the rule key in a base config file present in all environments.","Log the resolved key at startup to catch unresolved placeholders."],"tags":["sentinel","datasource","spring-cloud-config","constructor-validation","java"],"backgroundTag":null,"analyzedSha":"a3f40ba8e900c8489bd520274739f17235a7721c","analyzedAt":"2026-08-14T11:10:30.678Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}