{"record":{"id":"034e5a543e1a6280","repo":"EllanJiang/GameFramework","slug":"resource-group-name-is-invalid","errorCode":null,"errorMessage":"Resource group name is invalid.","messagePattern":"Resource group name is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.cs","lineNumber":2190,"sourceCode":"\n        /// <summary>\n        /// 获取资源组集合。\n        /// </summary>\n        /// <param name=\"resourceGroupNames\">要获取的资源组名称的集合。</param>\n        /// <returns>要获取的资源组集合。</returns>\n        public IResourceGroupCollection GetResourceGroupCollection(params string[] resourceGroupNames)\n        {\n            if (resourceGroupNames == null || resourceGroupNames.Length < 1)\n            {\n                throw new GameFrameworkException(\"Resource group names is invalid.\");\n            }\n\n            ResourceGroup[] resourceGroups = new ResourceGroup[resourceGroupNames.Length];\n            for (int i = 0; i < resourceGroupNames.Length; i++)\n            {\n                if (string.IsNullOrEmpty(resourceGroupNames[i]))\n                {\n                    throw new GameFrameworkException(\"Resource group name is invalid.\");\n                }\n\n                resourceGroups[i] = (ResourceGroup)GetResourceGroup(resourceGroupNames[i]);\n                if (resourceGroups[i] == null)\n                {\n                    throw new GameFrameworkException(Utility.Text.Format(\"Resource group '{0}' is not exist.\", resourceGroupNames[i]));\n                }\n            }\n\n            return new ResourceGroupCollection(resourceGroups, m_ResourceInfos);\n        }\n\n        /// <summary>\n        /// 获取资源组集合。\n        /// </summary>\n        /// <param name=\"resourceGroupNames\">要获取的资源组名称的集合。</param>\n        /// <returns>要获取的资源组集合。</returns>\n        public IResourceGroupCollection GetResourceGroupCollection(List<string> resourceGroupNames)","sourceCodeStart":2172,"sourceCodeEnd":2208,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.cs#L2172-L2208","documentation":"Inside GetResourceGroupCollection, each element of resourceGroupNames is validated: a null or empty name throws this GameFrameworkException. Every name must be a non-empty identifier of an existing resource group.","triggerScenarios":"Calling GetResourceGroupCollection with an array or list containing a null or empty string element, e.g. names containing \"\" from a split or config entry.","commonSituations":"Names parsed from a comma-separated config line with stray commas producing empty tokens, or uninitialized array slots.","solutions":["Remove or fix null/empty entries in the name list before calling","Trim and filter the parsed names: names.Where(n => !string.IsNullOrEmpty(n))","Correct the source config so it contains only valid group names"],"exampleFix":"// before\nvar col = manager.GetResourceGroupCollection(\"UI\", \"\", \"Scene\");\n// after\nvar valid = names.Where(n => !string.IsNullOrEmpty(n)).ToArray();\nvar col = manager.GetResourceGroupCollection(valid);","handlingStrategy":"validation","validationCode":"foreach (var n in names)\n    if (string.IsNullOrEmpty(n)) throw new ArgumentException(\"Group name entries must be non-empty\");","typeGuard":"bool AllNamesValid(IEnumerable<string> names) => names != null && names.All(n => !string.IsNullOrWhiteSpace(n));","tryCatchPattern":"try { var col = manager.GetResourceGroupCollection(names); }\ncatch (GameFrameworkException ex) when (ex.Message == \"Resource group name is invalid.\") { names = names.Where(n => !string.IsNullOrEmpty(n)).ToArray(); /* retry */ }","preventionTips":["Trim and filter parsed config tokens before use","Avoid Split without RemoveEmptyEntries","Validate user-provided names at input time"],"tags":["csharp","gameframework","invalid-argument","resource-groups"],"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-23T08:17:48.524Z"}