EllanJiang/GameFramework · error · GameFrameworkException

Entity group name is invalid.

Error message

Entity group name is invalid.

What it means

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.

Solutions

  1. Guard the name before calling: check string.IsNullOrEmpty(entityGroupName) and skip or fix the value.
  2. Fix the source of the empty string — blank config/inspector field or faulty string parsing.
  3. Validate entity group configuration at load time so blank names are caught early with a clear message.

Example fix

// before
bool exists = entityManager.HasEntityGroup(config.GroupName); // GroupName may be ""

// after
if (!string.IsNullOrEmpty(config.GroupName))
{
    bool exists = entityManager.HasEntityGroup(config.GroupName);
}
else
{
    Debug.LogError($"Entity definition {config.name} has no group name");
}
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrEmpty(entityGroupName))
{
    Debug.LogError("Entity group name is empty; check configuration");
    return false; // or fix/derive a valid name
}

Type guard

bool IsValidGroupName(string name) => !string.IsNullOrEmpty(name);

Try / catch

try
{
    exists = entityManager.HasEntityGroup(name);
}
catch (GameFrameworkException ex)
{
    Debug.LogWarning($"Invalid group name '{name}': {ex.Message}");
    exists = false;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/8af2f81f7a24bbea. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/Entity/EntityManager.cs:251

        {
            if (entityHelper == null)
            {
                throw new GameFrameworkException("Entity helper is invalid.");
            }

            m_EntityHelper = entityHelper;
        }

        /// <summary>
        /// 是否存在实体组。
        /// </summary>
        /// <param name="entityGroupName">实体组名称。</param>
        /// <returns>是否存在实体组。</returns>
        public bool HasEntityGroup(string entityGroupName)
        {
            if (string.IsNullOrEmpty(entityGroupName))
            {
                throw new GameFrameworkException("Entity group name is invalid.");
            }

            return m_EntityGroups.ContainsKey(entityGroupName);
        }

        /// <summary>
        /// 获取实体组。
        /// </summary>
        /// <param name="entityGroupName">实体组名称。</param>
        /// <returns>要获取的实体组。</returns>
        public IEntityGroup GetEntityGroup(string entityGroupName)
        {
            if (string.IsNullOrEmpty(entityGroupName))
            {
                throw new GameFrameworkException("Entity group name is invalid.");
            }

            EntityGroup entityGroup = null;

View on GitHub (pinned to d0c010b051)