{"record":{"id":"fe14b43ab0e6174a","repo":"EllanJiang/GameFramework","slug":"config-name-is-invalid","errorCode":null,"errorMessage":"Config name is invalid.","messagePattern":"Config name is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Config/ConfigManager.cs","lineNumber":475,"sourceCode":"                return false;\n            }\n\n            return m_ConfigDatas.Remove(configName);\n        }\n\n        /// <summary>\n        /// 清空所有全局配置项。\n        /// </summary>\n        public void RemoveAllConfigs()\n        {\n            m_ConfigDatas.Clear();\n        }\n\n        private ConfigData? GetConfigData(string configName)\n        {\n            if (string.IsNullOrEmpty(configName))\n            {\n                throw new GameFrameworkException(\"Config name is invalid.\");\n            }\n\n            ConfigData configData = default(ConfigData);\n            if (m_ConfigDatas.TryGetValue(configName, out configData))\n            {\n                return configData;\n            }\n\n            return null;\n        }\n    }\n}\n","sourceCodeStart":457,"sourceCodeEnd":488,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Config/ConfigManager.cs#L457-L488","documentation":"ConfigManager.GetConfigData throws 'Config name is invalid.' when the configName argument is null or empty. This happens before any dictionary lookup: the manager refuses to search for an unnamed config. It is reached indirectly by public APIs like HasConfig and the configData property, as well as Get* accessors, whenever they are handed an empty name.","triggerScenarios":"Calling HasConfig(null)/HasConfig(\"\"), accessing the configData indexer/property with an empty name, or propagating an empty config name variable from a UI field, parsed table row, or failed string split.","commonSituations":"Config name read from an uninitialized or blank input field; splitting a 'key=value' string where the key part is empty; deserialized settings missing the name field; refactoring that renamed the constant feeding the call.","solutions":["Validate the config name is a non-empty string before calling any ConfigManager API","Trace the caller (HasConfig/configData) to find where the empty name originates","Fix the upstream source (input field, split, deserialization) that produces the empty name"],"exampleFix":"// before\nbool exists = config.HasConfig(nameFromInput);\n// after\nif (!string.IsNullOrEmpty(nameFromInput))\n{\n    bool exists = config.HasConfig(nameFromInput);\n}","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(configName))\n{\n    throw new ArgumentException(\"Config name must be non-empty\", nameof(configName));\n}","typeGuard":"bool IsValidConfigName(string name) => !string.IsNullOrEmpty(name);","tryCatchPattern":"try { exists = config.HasConfig(name); }\ncatch (GameFrameworkException) { Log.Error(\"Empty config name passed to ConfigManager\"); exists = false; }","preventionTips":["Validate names at the boundary (UI, deserialization) before they reach ConfigManager","Check string.Split results for empty segments","Fail fast on empty names in your own wrapper layer","Avoid passing nullable string fields straight into config APIs"],"tags":["config","gameframework","null-or-empty","argument"],"backgroundTag":"empty-required-field","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"}