alibaba/Sentinel · error · IllegalArgumentException

Invalid DegradeRule:

Error message

Invalid DegradeRule: 

What it means

AbstractCircuitBreaker (base of CircuitBreakerRule and ResponseTimeCircuitBreaker) validates the DegradeRule via DegradeRuleManager.isValidRule(rule) before building the breaker. If the rule fails validation (null rule, or invalid grade/timeWindow/count combination) it throws IllegalArgumentException with the rule toString appended.

Source

Thrown at sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/degrade/circuitbreaker/AbstractCircuitBreaker.java:51

public abstract class AbstractCircuitBreaker implements CircuitBreaker {
    protected static final double MAX_RATIO = 1.0d;

    protected final DegradeRule rule;
    protected final int recoveryTimeoutMs;

    private final EventObserverRegistry observerRegistry;

    protected final AtomicReference<State> currentState = new AtomicReference<>(State.CLOSED);
    protected volatile long nextRetryTimestamp;

    public AbstractCircuitBreaker(DegradeRule rule) {
        this(rule, EventObserverRegistry.getInstance());
    }

    AbstractCircuitBreaker(DegradeRule rule, EventObserverRegistry observerRegistry) {
        AssertUtil.notNull(observerRegistry, "observerRegistry cannot be null");
        if (!DegradeRuleManager.isValidRule(rule)) {
            throw new IllegalArgumentException("Invalid DegradeRule: " + rule);
        }
        this.observerRegistry = observerRegistry;
        this.rule = rule;
        this.recoveryTimeoutMs = rule.getTimeWindow() * 1000;
    }

    @Override
    public DegradeRule getRule() {
        return rule;
    }

    @Override
    public State currentState() {
        return currentState.get();
    }

    @Override
    public boolean tryPass(Context context) {

View on GitHub (pinned to a3f40ba8e9)

Solutions

  1. Inspect the DegradeRule in the error message: ensure it is non-null and has grade, count, and timeWindow (seconds) set to valid values.
  2. Run DegradeRuleManager.isValidRule(rule) yourself before constructing a circuit breaker to get field-level errors.
  3. Fix the rule source (dashboard form / Nacos/Apollo config) — usually timeWindow must be > 0 and statIntervalMs/count within allowed bounds.

Example fix

// before
DegradeRule rule = new DegradeRule("foo");
rule.setGrade(RuleConstant.DEGRADE_GRADE_RT);
// timeWindow never set (0) -> invalid
new ResponseTimeCircuitBreaker(rule);

// after
DegradeRule rule = new DegradeRule("foo");
rule.setGrade(RuleConstant.DEGRADE_GRADE_RT);
rule.setCount(10);          // RT threshold ms
rule.setTimeWindow(10);     // recovery window, seconds
new ResponseTimeCircuitBreaker(rule);
Defensive patterns

Strategy: validation

Validate before calling

if (rule == null || !DegradeRuleManager.isValidRule(rule)) {
    // reject with details before building the circuit breaker
    throw new IllegalArgumentException("Invalid DegradeRule: " + rule);
}
CircuitBreaker cb = rule.getGrade() == RuleConstant.DEGRADE_GRADE_RT
    ? new ResponseTimeCircuitBreaker(rule)
    : new CircuitBreakerRule(rule);

Try / catch

catch (IllegalArgumentException e) {
    RecordLog.warn("Rejected invalid degrade rule " + rule, e);
    // skip this rule, keep processing the rest of the rule list
}

Prevention

When it happens

Trigger: new CircuitBreakerRule(degradeRule) or new ResponseTimeCircuitBreaker(degradeRule) where degradeRule is null, has timeWindow <= 0, or a count/grade combination DegradeRuleManager rejects; also triggered when registering an invalid rule via DegradeRuleManager.loadRules with circuit breaker types.

Common situations: Loading degrade rules from a dashboard or datasource where timeWindow was never set (defaults to 0), mixing old rule grades not supported by the circuit breaker strategy, or passing a rule whose count is negative.

Related errors


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