{"record":{"id":"e38ba492bb26032f","repo":"apache/shenyu","slug":"unknown-scaling-policy-s","errorCode":null,"errorMessage":"Unknown scaling policy: %s","messagePattern":"Unknown scaling policy: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"shenyu-admin/src/main/java/org/apache/shenyu/admin/scale/scaler/ScaleService.java","lineNumber":85,"sourceCode":"        ScalePolicyDO activePolicy = getActivePolicy();\n        if (Objects.nonNull(activePolicy)) {\n            switch (activePolicy.getId()) {\n                case \"1\":\n                    stopDynamicTask();\n                    kubernetesScaler.scaleByNum(activePolicy.getNum());\n                    break;\n                case \"2\":\n                    stopDynamicTask();\n                    if (isWithinTimeRange(activePolicy)) {\n                        kubernetesScaler.scaleByNum(activePolicy.getNum());\n                    }\n                    break;\n                case \"3\":\n                    startDynamicTask(scaleProperties.getMonitorInterval());\n                    break;\n                default:\n                    stopDynamicTask();\n                    throw new IllegalStateException(\"Unknown scaling policy: \" + activePolicy.getId());\n            }\n        }\n    }\n\n    /**\n     * get active policy.\n     *\n     * @return ScalePolicyDO\n     */\n    private ScalePolicyDO getActivePolicy() {\n        return scalePolicyCache.getAllPolicies().stream()\n                .filter(policy -> policy.getStatus() == 1)\n                .min(Comparator.comparingInt(ScalePolicyDO::getSort))\n                .orElseGet(() -> {\n                    LOG.warn(\"No active scaling policy found.\");\n                    return null;\n                });\n    }","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-admin/src/main/java/org/apache/shenyu/admin/scale/scaler/ScaleService.java#L67-L103","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (invalid policy row)\nINSERT INTO scale_policy (id, ...) VALUES ('custom-x', ...);\n// after (supported ids only)\nINSERT INTO scale_policy (id, ...) VALUES ('2', ...);","handlingStrategy":"validation","validationCode":"Set<String> valid = Set.of(\"1\", \"2\", \"3\");\nif (!valid.contains(activePolicy.getId()))\n    throw new IllegalStateException(\"policy id \" + activePolicy.getId() + \" is not a supported scaling policy\");","typeGuard":null,"tryCatchPattern":"try {\n    scaleService.executeScaling();\n} catch (IllegalStateException e) {\n    LOG.error(\"scaling aborted: {}\", e.getMessage()); // fall back to default policy\n}","preventionTips":["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"],"tags":["scaling","autoscaler","invalid-policy","configuration"],"backgroundTag":"invalid-enum-value","analyzedSha":"567142e07261b3e615ae8850b30f4421f455cc5d","analyzedAt":"2026-09-12T10:08:21.293Z","contentChangedAt":"2026-09-12T10:08:21.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}