{"record":{"id":"1f6284d821970505","repo":"EllanJiang/GameFramework","slug":"ui-group-name-is-invalid-uimanager","errorCode":null,"errorMessage":"UI group name is invalid.","messagePattern":"UI group name is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/UI/UIManager.cs","lineNumber":291,"sourceCode":"        {\n            if (uiFormHelper == null)\n            {\n                throw new GameFrameworkException(\"UI form helper is invalid.\");\n            }\n\n            m_UIFormHelper = uiFormHelper;\n        }\n\n        /// <summary>\n        /// 是否存在界面组。\n        /// </summary>\n        /// <param name=\"uiGroupName\">界面组名称。</param>\n        /// <returns>是否存在界面组。</returns>\n        public bool HasUIGroup(string uiGroupName)\n        {\n            if (string.IsNullOrEmpty(uiGroupName))\n            {\n                throw new GameFrameworkException(\"UI group name is invalid.\");\n            }\n\n            return m_UIGroups.ContainsKey(uiGroupName);\n        }\n\n        /// <summary>\n        /// 获取界面组。\n        /// </summary>\n        /// <param name=\"uiGroupName\">界面组名称。</param>\n        /// <returns>要获取的界面组。</returns>\n        public IUIGroup GetUIGroup(string uiGroupName)\n        {\n            if (string.IsNullOrEmpty(uiGroupName))\n            {\n                throw new GameFrameworkException(\"UI group name is invalid.\");\n            }\n\n            UIGroup uiGroup = null;","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/UI/UIManager.cs#L273-L309","documentation":"HasUIGroup looks up a UI group by name in the UIManager's dictionary; an empty or null name can never match a group, so it is rejected with an explicit GameFrameworkException instead of returning false. This fail-fast distinguishes 'you passed a bad argument' from 'the group does not exist', since returning false for an invalid name would mask caller bugs.","triggerScenarios":"Calling HasUIGroup(null) or HasUIGroup(\"\") — commonly when a group name variable was never set, or a UIForm instance carries an empty group name from bad configuration.","commonSituations":"UI form prefabs serialized with an empty group name field; config-driven UI layouts where the group name column is blank; string concatenation producing an empty name.","solutions":["Pass a non-empty UI group name that was previously added via AddUIGroup","Guard the caller: if (string.IsNullOrEmpty(name)) return; before calling HasUIGroup","Fix the source of the empty name (config file, prefab inspector field, or constructor default)","Use TryGetValue-style patterns via GetUIGroup only after validating the name"],"exampleFix":"// before\nbool exists = ui.HasUIGroup(groupName); // groupName may be \"\"\n// after\nif (!string.IsNullOrEmpty(groupName))\n{\n    bool exists = ui.HasUIGroup(groupName);\n}","handlingStrategy":"validation","validationCode":"if (!string.IsNullOrEmpty(uiGroupName))\n    exists = uiManager.HasUIGroup(uiGroupName);","typeGuard":"bool IsValidGroupName(string name) => !string.IsNullOrEmpty(name);","tryCatchPattern":"try { return uiManager.HasUIGroup(name); }\ncatch (GameFrameworkException) { return false; }","preventionTips":["Validate group names when loading them from config or inspector fields","Define group names as constants instead of ad-hoc strings","Trim config strings and reject blank entries at load time"],"tags":["empty-string","ui","argument-validation"],"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"}