Skip to content

fix(dashboard): reset field values when switching circuit breaker strategy#3605

Open
daguimu wants to merge 1 commit intoalibaba:masterfrom
daguimu:fix/dashboard-degrade-rule-display-issue3582
Open

fix(dashboard): reset field values when switching circuit breaker strategy#3605
daguimu wants to merge 1 commit intoalibaba:masterfrom
daguimu:fix/dashboard-degrade-rule-display-issue3582

Conversation

@daguimu
Copy link
Copy Markdown

@daguimu daguimu commented Mar 25, 2026

Problem

When editing or adding a circuit breaker (degrade) rule in the Sentinel dashboard, switching between strategies (slow call ratio / exception ratio / exception count) does not reset the threshold input field. For example, after setting max RT to 1000ms for slow call ratio strategy, switching to exception ratio still shows 1000 in the ratio threshold field, which is invalid since the valid range is [0.0, 1.0].

Root Cause

All three circuit breaker strategies share the same currentRule.count model in the dialog template. When the user switches the strategy via radio buttons, the count value is not cleared, causing the previous strategy's value to persist in the input field.

Fix

  • Added onGradeChange() handler in DegradeCtl controller that resets currentRule.count and currentRule.slowRatioThreshold to undefined when the strategy changes.
  • Added ng-change="onGradeChange()" to all three strategy radio buttons in degrade-rule-dialog.html.
  • The ng-change directive only fires on user interaction, so existing values are preserved when editing a rule (no reset on initial dialog load).

Tests

The dashboard frontend has no test infrastructure ("test": "echo no test case" in package.json). Manual verification steps:

  1. Open Sentinel dashboard, go to circuit breaker (degrade) rules page
  2. Add or edit a rule, select "Slow call ratio", set max RT to 1000
  3. Switch to "Exception ratio" — the threshold field should now be empty with placeholder text "[0.0, 1.0]"
  4. Switch to "Exception count" — the field should be empty with placeholder "异常数"
  5. Switch back to "Slow call ratio" — both RT and ratio threshold fields should be empty

Impact

Only affects the circuit breaker rule dialog UI in the dashboard. No backend or core logic changes.

Fixes #3582

…ategy

When switching between circuit breaker strategies (slow call ratio /
exception ratio / exception count) in the degrade rule dialog, the
count and slowRatioThreshold fields were not reset. This caused the
previous strategy's value (e.g., RT=1000) to remain in the input
field when switching to a different strategy (e.g., exception ratio
where the valid range is [0.0, 1.0]).

Add ng-change handler on the strategy radio buttons to clear both
count and slowRatioThreshold when the user switches strategies.

Fixes alibaba#3582
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant