{"record":{"id":"bfb6614e4172bc2a","repo":"apache/shardingsphere","slug":"can-not-find-yaml-rule-configuration-with-type-s","errorCode":null,"errorMessage":"Can not find YAML rule configuration with type: %s","messagePattern":"Can not find YAML rule configuration with type: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"mode/node/src/main/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleConfigurationReflectionEngine.java","lineNumber":58,"sourceCode":"public final class YamlRuleConfigurationReflectionEngine {\n    \n    /**\n     * Find YAML rule configuration class.\n     *\n     * @param ruleType rule type\n     * @return found class\n     * @throws IllegalArgumentException throw if YAML rule configuration class not found\n     */\n    @SuppressWarnings(\"rawtypes\")\n    public static Class<? extends YamlRuleConfiguration> findClass(final String ruleType) {\n        for (YamlRuleConfigurationSwapper each : ShardingSphereServiceLoader.getServiceInstances(YamlRuleConfigurationSwapper.class)) {\n            Class<? extends YamlRuleConfiguration> yamlRuleConfigClass = getYamlRuleConfigurationClass(each);\n            RuleNodeTupleEntity entity = yamlRuleConfigClass.getAnnotation(RuleNodeTupleEntity.class);\n            if (null != entity && entity.value().equals(ruleType)) {\n                return yamlRuleConfigClass;\n            }\n        }\n        throw new IllegalArgumentException(String.format(\"Can not find YAML rule configuration with type: %s\", ruleType));\n    }\n    \n    @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n    private static Class<? extends YamlRuleConfiguration> getYamlRuleConfigurationClass(final YamlRuleConfigurationSwapper swapper) {\n        return (Class<? extends YamlRuleConfiguration>) ((ParameterizedType) swapper.getClass().getGenericInterfaces()[0]).getActualTypeArguments()[0];\n    }\n    \n    /**\n     * Get YAML rule configuration fields.\n     *\n     * @param yamlRuleConfigClass YAML rule configuration class\n     * @return got fields\n     */\n    public static Collection<Field> getFields(final Class<? extends YamlRuleConfiguration> yamlRuleConfigClass) {\n        return Arrays.stream(yamlRuleConfigClass.getDeclaredFields())\n                .filter(each -> null != each.getAnnotation(RuleNodeTupleField.class))\n                .sorted(Comparator.comparingInt(o -> o.getAnnotation(RuleNodeTupleField.class).type().ordinal())).collect(Collectors.toList());\n    }","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/mode/node/src/main/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleConfigurationReflectionEngine.java#L40-L76","documentation":"Thrown by YamlRuleConfigurationReflectionEngine.findClass when no YamlRuleConfigurationSwapper on the service-loading path has a RuleNodeTupleEntity annotation whose value equals the requested rule type. The engine discovers YAML rule configuration classes by scanning swappers via ShardingSphereServiceLoader and reading their generic parameter's annotation; no match means the rule type is unknown to this installation.","triggerScenarios":"Rule-persist/reflection code asking for a rule type string (e.g. from a governance node path) that has no swapper: typos ('sharding' vs 'shardings'), custom rule types whose swapper JAR is missing from the classpath, or a rule introduced in a newer version than the deployed one.","commonSituations":"Custom or third-party rule SPI implementations without a META-INF/services registration, partial upgrades where the node content contains a newer rule type than the runtime understands, or a renamed rule tuple value across versions.","solutions":["Verify the rule type string exactly matches the @RuleNodeTupleEntity value of an available swapper implementation.","Ensure the module providing the YamlRuleConfigurationSwapper (and its META-INF/services entry) is on the classpath of the process doing the reflection.","For custom rules, annotate the YAML configuration class with @RuleNodeTupleEntity and register the swapper via ShardingSphereServiceLoader."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"boolean known = ShardingSphereServiceLoader.getServiceInstances(YamlRuleConfigurationSwapper.class).stream()\n    .map(YamlRuleConfigurationReflectionEngine::getYamlRuleConfigurationClass)\n    .map(c -> c.getAnnotation(RuleNodeTupleEntity.class))\n    .anyMatch(a -> null != a && a.value().equals(ruleType));","typeGuard":null,"tryCatchPattern":"try {\n    Class<? extends YamlRuleConfiguration> clazz = YamlRuleConfigurationReflectionEngine.findClass(ruleType);\n} catch (final IllegalArgumentException ex) {\n    // rule type has no swapper: check spelling, classpath, SPI registration\n}","preventionTips":["Derive rule type strings from @RuleNodeTupleEntity values, not hand-typed literals","Ship custom swappers with META-INF/services entries and keep them on every consuming classpath","After upgrades, reconcile governance node rule paths against the new tuple vocabulary"],"tags":["yaml","rule-configuration","spi","classloading"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}