alibaba/Sentinel · error · IllegalArgumentException

Bad argument: ruleKey=[%s]

Error message

Bad argument: ruleKey=[%s]

What it means

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.

Source

Thrown at sentinel-extension/sentinel-datasource-spring-cloud-config/src/main/java/com/alibaba/csp/sentinel/datasource/spring/cloud/config/SpringCloudConfigDataSource.java:54

 * </p>
 *
 * @author lianglin
 * @since 1.7.0
 */
public class SpringCloudConfigDataSource<T> extends AbstractDataSource<String, T> {

    private final static Map<SpringCloudConfigDataSource, SpringConfigListener> listeners;

    static {
        listeners = new ConcurrentHashMap<>();
    }

    private final String ruleKey;

    public SpringCloudConfigDataSource(final String ruleKey, Converter<String, T> converter) {
        super(converter);
        if (StringUtil.isBlank(ruleKey)) {
            throw new IllegalArgumentException(String.format("Bad argument: ruleKey=[%s]", ruleKey));
        }

        this.ruleKey = ruleKey;
        loadInitialConfig();
        initListener();
    }

    private void loadInitialConfig() {
        try {
            T newValue = loadConfig();
            if (newValue == null) {
                RecordLog.warn("[SpringCloudConfigDataSource] WARN: initial application is null, you may have to check your data source");
            }
            getProperty().updateValue(newValue);
        } catch (Exception ex) {
            RecordLog.warn("[SpringCloudConfigDataSource] Error when loading initial application", ex);
        }
    }

View on GitHub (pinned to a3f40ba8e9)

Solutions

  1. 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.
  2. Verify the key on the Config Server side (the property must exist there) and in local bootstrap/application config.
  3. Log the resolved ruleKey value before constructing so unresolved placeholders are visible at startup.

Example fix

// before
new SpringCloudConfigDataSource<>(env.getProperty("sentinel.rule.key"), converter); // null if unset

// after
String ruleKey = Objects.requireNonNull(env.getProperty("sentinel.rule.key"),
    "sentinel.rule.key must be set");
new SpringCloudConfigDataSource<>(ruleKey, converter);
Defensive patterns

Strategy: validation

Validate before calling

String ruleKey = env.getProperty("sentinel.rule.key");
if (StringUtil.isBlank(ruleKey)) {
    throw new IllegalArgumentException("sentinel.rule.key must be set (e.g. my-app-flow-rules)");
}
new SpringCloudConfigDataSource<>(ruleKey, converter);

Try / catch

try {
    new SpringCloudConfigDataSource<>(ruleKey, converter);
} catch (IllegalArgumentException e) {
    throw new IllegalStateException("SpringCloudConfigDataSource ruleKey not configured", e);
}

Prevention

When it happens

Trigger: new SpringCloudConfigDataSource(ruleKey, converter) with an unresolved placeholder ("${sentinel.flow-rule.key}" never substituted), a null property lookup, or an empty string literal.

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

Related errors


AI-assisted analysis of alibaba/Sentinel@a3f40ba8e9 (2026-08-14). Data as JSON: /api/errors/572517e6200ab63f. Report an issue: GitHub.