apache/shenyu · error · IllegalStateException
Unknown scaling policy
Error message
Unknown scaling policy: %s
What it means
ScaleService.executeScaling switches on the active scaling policy's id: "1" (manual/static), "2" and "3" (timed/dynamic tasks). Any other id throws IllegalStateException after stopping dynamic tasks, meaning the configured scaling policy id is not recognized by the scaler.
Solutions
- Inspect the active scaling policy (scale/scaler config in admin DB or dashboard) and reset its id to 1, 2, or 3.
- Re-create the scaling policy through the admin dashboard/API instead of manual DB edits.
- Remove or disable the invalid policy row so the default branch (stopDynamicTask) path or a valid policy is selected.
- Check for ShenYu version skew — policy ids must match what the running ScaleService supports.
Example fix
// before (invalid policy row)
INSERT INTO scale_policy (id, ...) VALUES ('custom-x', ...);
// after (supported ids only)
INSERT INTO scale_policy (id, ...) VALUES ('2', ...); Defensive patterns
Strategy: validation
Validate before calling
Set<String> valid = Set.of("1", "2", "3");
if (!valid.contains(activePolicy.getId()))
throw new IllegalStateException("policy id " + activePolicy.getId() + " is not a supported scaling policy"); Try / catch
try {
scaleService.executeScaling();
} catch (IllegalStateException e) {
LOG.error("scaling aborted: {}", e.getMessage()); // fall back to default policy
} Prevention
- Create scaling policies only through the admin dashboard/API
- Never hand-edit the scale policy table
- Validate policy id against {1,2,3} after DB restores or migrations
When it happens
Trigger: The active scaling policy record in the admin DB (scale policy table) has an id other than "1", "2" or "3" — e.g. a policy created by custom code, a corrupted row, or a version whose policy ids changed.
Common situations: Manually inserted/edited scale policy rows; restored DB data from another ShenYu version; plugin/extension creating policies with custom ids; leftover test data in the scaling policy table.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- shenyu.jwt.secretKey is not configured. In a multi-instance…
- shenyu discovery mode current didn't support
- websocket on client open failed, namespaceId is null
- websocket sync token is not configured
- e.getMessage()
AI-assisted analysis of apache/shenyu@567142e072 (2026-09-12).
Data as JSON: /api/errors/e38ba492bb26032f.
Report an issue: GitHub.
Appendix: source
Thrown at shenyu-admin/src/main/java/org/apache/shenyu/admin/scale/scaler/ScaleService.java:85
ScalePolicyDO activePolicy = getActivePolicy();
if (Objects.nonNull(activePolicy)) {
switch (activePolicy.getId()) {
case "1":
stopDynamicTask();
kubernetesScaler.scaleByNum(activePolicy.getNum());
break;
case "2":
stopDynamicTask();
if (isWithinTimeRange(activePolicy)) {
kubernetesScaler.scaleByNum(activePolicy.getNum());
}
break;
case "3":
startDynamicTask(scaleProperties.getMonitorInterval());
break;
default:
stopDynamicTask();
throw new IllegalStateException("Unknown scaling policy: " + activePolicy.getId());
}
}
}
/**
* get active policy.
*
* @return ScalePolicyDO
*/
private ScalePolicyDO getActivePolicy() {
return scalePolicyCache.getAllPolicies().stream()
.filter(policy -> policy.getStatus() == 1)
.min(Comparator.comparingInt(ScalePolicyDO::getSort))
.orElseGet(() -> {
LOG.warn("No active scaling policy found.");
return null;
});
}View on GitHub (pinned to 567142e072)