{"record":{"id":"69752d845bc6202e","repo":"apache/dubbo","slug":"scope-model-is-invalid-scopemodel","errorCode":null,"errorMessage":"scope model is invalid: <scopeModel>","messagePattern":"scope model is invalid: <scopeModel>","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java","lineNumber":429,"sourceCode":"            // For compatibility, key like \"registry-type\" will have a duplicate key \"registry.type\"\n            if (Arrays.binarySearch(Constants.DOT_COMPATIBLE_KEYS, key) >= 0) {\n                result.put(pre + key.replace('-', '.'), value);\n            }\n        }\n        return result;\n    }\n\n    @Transient\n    public ApplicationModel getApplicationModel() {\n        if (scopeModel == null) {\n            setScopeModel(getDefaultModel());\n        }\n        if (scopeModel instanceof ApplicationModel) {\n            return (ApplicationModel) scopeModel;\n        } else if (scopeModel instanceof ModuleModel) {\n            return ((ModuleModel) scopeModel).getApplicationModel();\n        } else {\n            throw new IllegalStateException(\"scope model is invalid: \" + scopeModel);\n        }\n    }\n\n    @Transient\n    public ScopeModel getScopeModel() {\n        if (scopeModel == null) {\n            setScopeModel(getDefaultModel());\n        }\n        return scopeModel;\n    }\n\n    @Transient\n    protected ScopeModel getDefaultModel() {\n        return ApplicationModel.defaultModel();\n    }\n\n    public final void setScopeModel(ScopeModel scopeModel) {\n        if (scopeModel != null && this.scopeModel != scopeModel) {","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java#L411-L447","documentation":"Thrown by AbstractConfig.getApplicationModel(): the scopeModel is non-null and set, but it is neither an ApplicationModel nor a ModuleModel. After auto-defaulting (which would assign ApplicationModel.defaultModel()), reaching this branch means an exotic/invalid ScopeModel subtype was injected.","triggerScenarios":"setScopeModel was called with a ScopeModel that is not ApplicationModel or ModuleModel (e.g. a FrameworkModel or a custom ScopeModel subclass), and getApplicationModel() is later called. This is rare; the default path assigns an ApplicationModel.","commonSituations":"Programmatically calling config.setScopeModel(frameworkModel) by mistake. A custom ScopeModel subclass was used. Internal Dubbo model wiring bug after a partial migration between Dubbo versions.","solutions":["Ensure you pass an ApplicationModel (or ModuleModel) to setScopeModel, not a FrameworkModel.","If you only have a FrameworkModel, obtain its application model: frameworkModel.defaultApplicationModel() / getDefaultModule().","Avoid calling setScopeModel with null/custom subtypes; let Dubbo default it.","On upgrade, verify model wiring matches the Dubbo version's ScopeModel hierarchy."],"exampleFix":"// before\nconfig.setScopeModel(frameworkModel); // wrong type\n// after\nconfig.setScopeModel(frameworkModel.defaultApplicationModel());","handlingStrategy":"type-guard","validationCode":"void safeSetScopeModel(AbstractConfig cfg, ScopeModel m) {\n    if (m instanceof ApplicationModel || m instanceof ModuleModel) {\n        cfg.setScopeModel(m);\n    } else {\n        throw new IllegalArgumentException(\"expected ApplicationModel/ModuleModel, got \" + m);\n    }\n}","typeGuard":"boolean isAcceptableScopeModel(ScopeModel m) {\n    return m instanceof ApplicationModel || m instanceof ModuleModel;\n}","tryCatchPattern":"try {\n    return config.getApplicationModel();\n} catch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"scope model is invalid\")) { /* reset to default model */ }\n    throw e;\n}","preventionTips":["Pass only ApplicationModel (or ModuleModel where supported) to setScopeModel.","Derive the application model from a framework model via defaultApplicationModel().","Avoid custom ScopeModel subtypes unless you fully control the hierarchy."],"tags":["config","scope-model","application-model","startup"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}