apache/shenyu · error · ShenyuAdminException
scale rule is not existed
Error message
scale rule is not existed
What it means
PUT /scale/rule (ScaleRlueController.updateRule) checks scaleRuleMapper.existed(id) before updating; when no scale rule row exists for the DTO's id it throws ShenyuAdminException("scale rule is not existed"). Updates are id-based and never create-or-upsert.
Solutions
- Confirm the rule id exists (GET the rule list / check the scale_rule table) and send the correct id
- If the rule is new, use POST (createRule) instead of PUT
- Refresh the dashboard page to clear stale ids and retry
Example fix
// before
PUT /scale/rule {"id":"nonexistent-id", ...}
// after
POST /scale/rule {"name":"my-rule", ...} // create first, then PUT with returned id Defensive patterns
Strategy: validation
Validate before calling
ScaleRuleDTO existing = scaleRuleApi.getById(dto.getId());
if (existing == null) {
scaleRuleApi.createRule(dto); // create instead of update
} else {
scaleRuleApi.updateRule(dto);
} Try / catch
try {
scaleRuleApi.updateRule(dto);
} catch (ShenyuAdminException e) {
if ("scale rule is not existed".equals(e.getMessage())) { scaleRuleApi.createRule(dto); }
} Prevention
- Fetch the current rule list before updating and use ids from that response
- Never hardcode scale rule ids in scripts
- Refresh dashboards to avoid stale ids from deleted rules
When it happens
Trigger: PUT /scale/rule with a ScaleRuleDTO whose id does not exist in the scale_rule table (stale id, id from another environment, or calling update instead of create for a new rule).
Common situations: Dashboard stale tab holding a rule deleted elsewhere; automation scripts reusing hardcoded ids; confusing create (POST) with update (PUT) semantics.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
AI-assisted analysis of apache/shenyu@567142e072 (2026-09-12).
Data as JSON: /api/errors/d09932bdbc2b7a4e.
Report an issue: GitHub.
Appendix: source
Thrown at shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ScaleRlueController.java:130
*
* @param scaleRuleDTO scaleRuleDTO
* @return ShenyuAdminResult
*/
@PostMapping
public ShenyuAdminResult createRule(@Valid @RequestBody final ScaleRuleDTO scaleRuleDTO) {
return ShenyuAdminResult.success(ShenyuResultMessage.CREATE_SUCCESS, scaleRuleService.createOrUpdate(scaleRuleDTO));
}
/**
* update rule.
*
* @param scaleRuleDTO scaleRuleDTO
* @return ShenyuAdminResult
*/
@PutMapping
public ShenyuAdminResult updateRule(@Valid @RequestBody final ScaleRuleDTO scaleRuleDTO) {
if (!scaleRuleMapper.existed(scaleRuleDTO.getId())) {
throw new ShenyuAdminException("scale rule is not existed");
}
return ShenyuAdminResult.success(ShenyuResultMessage.UPDATE_SUCCESS, scaleRuleService.createOrUpdate(scaleRuleDTO));
}
/**
* delete rules.
*
* @param ids ids
* @return ShenyuAdminResult
*/
@DeleteMapping("/batch")
public ShenyuAdminResult deleteRules(@RequestBody @NotEmpty final List<@NotBlank String> ids) {
return ShenyuAdminResult.success(ShenyuResultMessage.DELETE_SUCCESS, scaleRuleService.delete(ids));
}
}
View on GitHub (pinned to 567142e072)