{"record":{"id":"f2394aa6555f36ac","repo":"EllanJiang/GameFramework","slug":"config-helper-is-invalid","errorCode":null,"errorMessage":"Config helper is invalid.","messagePattern":"Config helper is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Config/ConfigManager.cs","lineNumber":157,"sourceCode":"\n        /// <summary>\n        /// 设置全局配置数据提供者辅助器。\n        /// </summary>\n        /// <param name=\"dataProviderHelper\">全局配置数据提供者辅助器。</param>\n        public void SetDataProviderHelper(IDataProviderHelper<IConfigManager> dataProviderHelper)\n        {\n            m_DataProvider.SetDataProviderHelper(dataProviderHelper);\n        }\n\n        /// <summary>\n        /// 设置全局配置辅助器。\n        /// </summary>\n        /// <param name=\"configHelper\">全局配置辅助器。</param>\n        public void SetConfigHelper(IConfigHelper configHelper)\n        {\n            if (configHelper == null)\n            {\n                throw new GameFrameworkException(\"Config helper is invalid.\");\n            }\n\n            m_ConfigHelper = configHelper;\n        }\n\n        /// <summary>\n        /// 确保二进制流缓存分配足够大小的内存并缓存。\n        /// </summary>\n        /// <param name=\"ensureSize\">要确保二进制流缓存分配内存的大小。</param>\n        public void EnsureCachedBytesSize(int ensureSize)\n        {\n            DataProvider<IConfigManager>.EnsureCachedBytesSize(ensureSize);\n        }\n\n        /// <summary>\n        /// 释放缓存的二进制流。\n        /// </summary>\n        public void FreeCachedBytes()","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Config/ConfigManager.cs#L139-L175","documentation":"ConfigManager.SetConfigHelper stores the global config helper (interface bridge between the framework and the host engine, e.g. Unity's ConfigHelper). A null helper would break all config loading later, so it is rejected at assignment time.","triggerScenarios":"Calling SetConfigHelper(null) or passing a helper field that was never assigned, e.g. forgetting to add the ConfigHelper component to a Unity GameObject before initialization.","commonSituations":"GameFramework component setup ordering issues: the helper MonoBehaviour isn't attached/created yet; custom helper class deleted during refactor leaving a null field.","solutions":["Create/attach the helper before registration (e.g. new DefaultConfigHelper() or AddComponent<ConfigHelper>())","Verify the helper field/property is initialized in the component's Awake","Assert non-null at the call site to catch the misconfiguration early"],"exampleFix":"// before\nm_ConfigManager.SetConfigHelper(m_ConfigHelper); // null\n// after\nm_ConfigHelper = m_ConfigHelper ?? new DefaultConfigHelper();\nm_ConfigManager.SetConfigHelper(m_ConfigHelper);","handlingStrategy":"type-guard","validationCode":"if (configHelper == null) { configHelper = new DefaultConfigHelper(); }\nconfigManager.SetConfigHelper(configHelper);","typeGuard":"bool Ready(IConfigHelper h) => h != null;","tryCatchPattern":"try { configManager.SetConfigHelper(helper); }\ncatch (GameFrameworkException ex) { Debug.LogError($\"Config helper setup failed: {ex.Message}\"); }","preventionTips":["Attach/create the helper component before framework initialization","Verify GameObject wiring in scenes/prefabs after refactors","Register helpers in a fixed Awake order"],"tags":["config","null-argument","setup","gameframework"],"backgroundTag":"null-argument","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}