{"record":{"id":"cbb50954ee37c06b","repo":"apache/dubbo","slug":"add-default-config-failed-configtype-getsimplena","errorCode":null,"errorMessage":"Add default config failed: <configType.getSimpleName()>","messagePattern":"Add default config failed: <configType\\.getSimpleName\\(\\)>","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/config/context/AbstractConfigManager.java","lineNumber":621,"sourceCode":"     */\n    private Set<String> getConfigIdsFromProps(Class<? extends AbstractConfig> clazz) {\n        String prefix = CommonConstants.DUBBO + \".\" + AbstractConfig.getPluralTagName(clazz) + \".\";\n        return ConfigurationUtils.getSubIds(environment.getConfigurationMaps(), prefix);\n    }\n\n    protected <T extends AbstractConfig> void checkDefaultAndValidateConfigs(Class<T> configType) {\n        try {\n            if (shouldAddDefaultConfig(configType)) {\n                T config = createConfig(configType, scopeModel);\n                config.refresh();\n                if (!isNeedValidation(config) || config.isValid()) {\n                    this.addConfig(config);\n                } else {\n                    logger.info(\"Ignore invalid config: \" + config);\n                }\n            }\n        } catch (Exception e) {\n            throw new IllegalStateException(\"Add default config failed: \" + configType.getSimpleName(), e);\n        }\n\n        // validate configs\n        Collection<T> configs = this.getConfigs(configType);\n        if (getConfigValidator() != null) {\n            for (T config : configs) {\n                getConfigValidator().validate(config);\n            }\n        }\n\n        // check required default\n        if (isRequired(configType) && configs.isEmpty()) {\n            throw new IllegalStateException(\"Default config not found for \" + configType.getSimpleName());\n        }\n    }\n\n    /**\n     * The component configuration that does not affect the main process does not need to be verified.","sourceCodeStart":603,"sourceCodeEnd":639,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/config/context/AbstractConfigManager.java#L603-L639","documentation":"Thrown by AbstractConfigManager.checkDefaultAndValidateConfigs() when adding a generated default config (for a required type lacking an explicit one) fails with any exception. The method first tries to create and refresh a default config; if that construction or refresh throws, it wraps the failure with the config type simple name. Validation or required-default logic surfaces here.","triggerScenarios":"A config type marked for default creation whose default construction/refresh throws (e.g. default ApplicationConfig cannot resolve a required property). Called during the validate phase of bootstrap.","commonSituations":"Missing a required config and the auto-default path also fails due to environment issues (e.g. default registry address unresolvable). A custom required config type whose default builder is broken.","solutions":["Provide an explicit config of the required type so the default-creation path is skipped.","Inspect the wrapped cause to find why default construction failed.","Ensure environment/properties needed by the default config are present."],"exampleFix":"// before: relying on auto-default that fails\n// (no application config, default creation throws)\n// after: explicit config\nApplicationConfig app = new ApplicationConfig();\napp.setName(\"myApp\");\nconfigManager.addConfig(app);","handlingStrategy":"try-catch","validationCode":"// Provide explicit required config to bypass default-creation path\nif (configManager.getConfigs(ApplicationConfig.class).isEmpty()) {\n    ApplicationConfig app = new ApplicationConfig();\n    app.setName(\"myApp\");\n    configManager.addConfig(app);\n}\nconfigManager.checkDefaultAndValidateConfigs(ApplicationConfig.class);","typeGuard":"static boolean hasConfigOfType(ConfigManager cm, Class<? extends AbstractConfig> cls) {\n    return !cm.getConfigs(cls).isEmpty();\n}","tryCatchPattern":"try {\n    configManager.checkDefaultAndValidateConfigs(ApplicationConfig.class);\n} catch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"Add default config failed\")) {\n        ApplicationConfig app = new ApplicationConfig();\n        app.setName(\"myApp\");\n        configManager.addConfig(app);\n    } else throw e;\n}","preventionTips":["Always define required configs (application) explicitly in bootstrap.","Set dubbo.application.name in Spring Boot properties.","Write a startup smoke test that validates configs."],"tags":["config","default-config","validation","startup"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}