{"record":{"id":"6f93ef6659a7680f","repo":"alibaba/spring-cloud-alibaba","slug":"namespacename-flowruleskey-and-defaultflowruleva","errorCode":null,"errorMessage":"namespaceName, flowRulesKey, and defaultFlowRuleValue must not be null","messagePattern":"namespaceName, flowRulesKey, and defaultFlowRuleValue must not be null","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"spring-cloud-alibaba-starters/spring-cloud-alibaba-sentinel-datasource/src/main/java/com/alibaba/cloud/sentinel/datasource/factorybean/ApolloDataSourceFactoryBean.java","lineNumber":44,"sourceCode":" * A {@link FactoryBean} for creating {@link ApolloDataSource} instance.\n *\n * @author <a href=\"mailto:fangjian0423@gmail.com\">Jim</a>\n * @see ApolloDataSource\n */\npublic class ApolloDataSourceFactoryBean implements FactoryBean<ApolloDataSource> {\n\n\tprivate @Nullable String namespaceName;\n\n\tprivate @Nullable String flowRulesKey;\n\n\tprivate @Nullable String defaultFlowRuleValue;\n\n\tprivate @Nullable Converter converter;\n\n\t@Override\n\tpublic ApolloDataSource getObject() throws Exception {\n\t\tif (namespaceName == null || flowRulesKey == null || defaultFlowRuleValue == null) {\n\t\t\tthrow new IllegalStateException(\"namespaceName, flowRulesKey, and defaultFlowRuleValue must not be null\");\n\t\t}\n\t\treturn new ApolloDataSource(namespaceName, flowRulesKey, defaultFlowRuleValue,\n\t\t\t\tconverter);\n\t}\n\n\t@Override\n\tpublic Class<?> getObjectType() {\n\t\treturn ApolloDataSource.class;\n\t}\n\n\tpublic @Nullable String getNamespaceName() {\n\t\treturn namespaceName;\n\t}\n\n\tpublic void setNamespaceName(@Nullable String namespaceName) {\n\t\tthis.namespaceName = namespaceName;\n\t}\n","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/alibaba/spring-cloud-alibaba/blob/115d5901102009492e05d5ec18c3f79cad4077d0/spring-cloud-alibaba-starters/spring-cloud-alibaba-sentinel-datasource/src/main/java/com/alibaba/cloud/sentinel/datasource/factorybean/ApolloDataSourceFactoryBean.java#L26-L62","documentation":"Thrown by ApolloDataSourceFactoryBean.getObject() when any of namespaceName, flowRulesKey, or defaultFlowRuleValue is null. This FactoryBean creates an ApolloDataSource for Sentinel rule sourcing from Apollo configuration center. The check is a simple null-or guard — all three fields are @Nullable with no defaults, so all must be explicitly provided. This fires during Spring bean initialization when getObject() is called by the FactoryBean infrastructure.","triggerScenarios":"Configuring a Sentinel datasource of type 'apollo' and omitting one or more of the three required properties: namespaceName, flowRulesKey, or defaultFlowRuleValue. The FactoryBean fields are populated from spring.cloud.sentinel.datasource.<name>.apollo.* properties; if any is absent, the null check triggers.","commonSituations":"1) Developer provides namespaceName and flowRulesKey but forgets defaultFlowRuleValue. 2) Apollo namespace or key was renamed but application config not updated. 3) Migration from another datasource type (e.g., file) where defaultFlowRuleValue was not needed and is overlooked.","solutions":["Provide all three properties: spring.cloud.sentinel.datasource.<name>.apollo.namespace-name, flow-rules-key, and default-flow-rule-value.","Verify the namespaceName matches an existing Apollo namespace and flowRulesKey matches a key within that namespace.","Set defaultFlowRuleValue to a valid empty-rule JSON array '[]' if no default fallback rules are needed."],"exampleFix":"# before (broken — defaultFlowRuleValue missing)\nspring:\n  cloud:\n    sentinel:\n      datasource:\n        ds1:\n          apollo:\n            namespace-name: application\n            flow-rules-key: sentinel.flow.rules\n\n# after (fixed)\nspring:\n  cloud:\n    sentinel:\n      datasource:\n        ds1:\n          apollo:\n            namespace-name: application\n            flow-rules-key: sentinel.flow.rules\n            default-flow-rule-value: \"[]\"","handlingStrategy":"validation","validationCode":"// Validate Apollo datasource properties before FactoryBean.getObject()\nApolloDataSourceFactoryBean fb = new ApolloDataSourceFactoryBean();\nif (namespaceName == null || flowRulesKey == null || defaultFlowRuleValue == null) {\n    throw new IllegalStateException(\n        \"ApolloDataSource requires namespaceName, flowRulesKey, and defaultFlowRuleValue\");\n}\nfb.setNamespaceName(namespaceName);\nfb.setFlowRulesKey(flowRulesKey);\nfb.setDefaultFlowRuleValue(defaultFlowRuleValue);\nfb.setConverter(converter);\nfb.getObject();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always provide all three Apollo properties (namespace-name, flow-rules-key, default-flow-rule-value) in configuration.","Set default-flow-rule-value to '[]' (empty array) if no fallback rules are needed.","Verify the Apollo namespace and key exist in the Apollo portal before deploying."],"tags":["sentinel","apollo","datasource","factory-bean","configuration","validation"],"backgroundTag":null,"analyzedSha":"115d5901102009492e05d5ec18c3f79cad4077d0","analyzedAt":"2026-08-14T04:47:13.900Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}