{"record":{"id":"8af2f81f7a24bbea","repo":"EllanJiang/GameFramework","slug":"entity-group-name-is-invalid-entitymanager","errorCode":null,"errorMessage":"Entity group name is invalid.","messagePattern":"Entity group name is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Entity/EntityManager.cs","lineNumber":251,"sourceCode":"        {\n            if (entityHelper == null)\n            {\n                throw new GameFrameworkException(\"Entity helper is invalid.\");\n            }\n\n            m_EntityHelper = entityHelper;\n        }\n\n        /// <summary>\n        /// 是否存在实体组。\n        /// </summary>\n        /// <param name=\"entityGroupName\">实体组名称。</param>\n        /// <returns>是否存在实体组。</returns>\n        public bool HasEntityGroup(string entityGroupName)\n        {\n            if (string.IsNullOrEmpty(entityGroupName))\n            {\n                throw new GameFrameworkException(\"Entity group name is invalid.\");\n            }\n\n            return m_EntityGroups.ContainsKey(entityGroupName);\n        }\n\n        /// <summary>\n        /// 获取实体组。\n        /// </summary>\n        /// <param name=\"entityGroupName\">实体组名称。</param>\n        /// <returns>要获取的实体组。</returns>\n        public IEntityGroup GetEntityGroup(string entityGroupName)\n        {\n            if (string.IsNullOrEmpty(entityGroupName))\n            {\n                throw new GameFrameworkException(\"Entity group name is invalid.\");\n            }\n\n            EntityGroup entityGroup = null;","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Entity/EntityManager.cs#L233-L269","documentation":"HasEntityGroup validates its argument and throws a GameFrameworkException when the entity group name is null or the empty string. GameFramework treats group names as required identifiers (the dictionary key in m_EntityGroups), so querying with an empty name is considered a programming error rather than a legitimate 'not found' result.","triggerScenarios":"Calling EntityManager.HasEntityGroup(null) or HasEntityGroup(\"\") — often when the group name comes from configuration, a string variable that was never initialized, or string.Split/substring logic that produced an empty value. Also surfaces internally via AddEntityGroup called with an empty name.","commonSituations":"Data-driven entity group setup where the group name field in a config/ScriptableObject/inspector is left blank, uninitialized string fields in entity definition assets, or parsing code that yields empty tokens for trailing delimiters.","solutions":["Guard the name before calling: check string.IsNullOrEmpty(entityGroupName) and skip or fix the value.","Fix the source of the empty string — blank config/inspector field or faulty string parsing.","Validate entity group configuration at load time so blank names are caught early with a clear message."],"exampleFix":"// before\nbool exists = entityManager.HasEntityGroup(config.GroupName); // GroupName may be \"\"\n\n// after\nif (!string.IsNullOrEmpty(config.GroupName))\n{\n    bool exists = entityManager.HasEntityGroup(config.GroupName);\n}\nelse\n{\n    Debug.LogError($\"Entity definition {config.name} has no group name\");\n}","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(entityGroupName))\n{\n    Debug.LogError(\"Entity group name is empty; check configuration\");\n    return false; // or fix/derive a valid name\n}","typeGuard":"bool IsValidGroupName(string name) => !string.IsNullOrEmpty(name);","tryCatchPattern":"try\n{\n    exists = entityManager.HasEntityGroup(name);\n}\ncatch (GameFrameworkException ex)\n{\n    Debug.LogWarning($\"Invalid group name '{name}': {ex.Message}\");\n    exists = false;\n}","preventionTips":["Validate entity group names when loading config/asset definitions.","Never call group APIs with string fields that may be blank from the inspector.","Sanitize parsing output (trim, reject empty tokens) before using names as keys."],"tags":["gameframework","entity","argument-validation","empty-string"],"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"}