egametang/ET · error

config group is empty: {factory.GetType().FullName}

Error message

config group is empty: {factory.GetType().FullName}

What it means

Thrown by ConfigFactoryGroupCollection.Add when the configGroup argument is null/empty/whitespace. The group name selects which variant of a factory is active (e.g. Config vs a StartConfig override); an empty group is ambiguous and cannot be keyed in the inner Dictionary, so Add rejects it. The group is derived from the factory type's ConfigGroupAttribute (GetConfigGroup), defaulting to ConfigGroupNames.Config when absent.

Source

Thrown at Packages/cn.etetet.loader/Scripts/Loader/Share/ConfigLoaderHelper.cs:20

using System.Collections.Generic;
using System.Reflection;

namespace ET
{
    public sealed class ConfigFactoryGroupCollection
    {
        private readonly Dictionary<Type, Dictionary<string, IConfigFactory>> factories = new();

        public void Add(string configGroup, IConfigFactory factory)
        {
            if (factory.ConfigType == null)
            {
                throw new Exception($"config factory target is null: {factory.GetType().FullName}");
            }

            if (string.IsNullOrWhiteSpace(configGroup))
            {
                throw new Exception($"config group is empty: {factory.GetType().FullName}");
            }

            if (!this.factories.TryGetValue(factory.ConfigType, out Dictionary<string, IConfigFactory> groupFactories))
            {
                groupFactories = new Dictionary<string, IConfigFactory>(StringComparer.Ordinal);
                this.factories.Add(factory.ConfigType, groupFactories);
            }

            if (!groupFactories.TryAdd(configGroup, factory))
            {
                throw new Exception($"duplicate config factory: {factory.ConfigType.FullName} group={configGroup}");
            }
        }

        public bool TryGetFactories(Type configType, out Dictionary<string, IConfigFactory> groupFactories)
        {
            return this.factories.TryGetValue(configType, out groupFactories);
        }

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Remove the empty ConfigGroupAttribute so GetConfigGroup falls back to ConfigGroupNames.Config, OR set a real group name.
  2. If a custom default is desired, fix GetConfigGroup to treat empty as the default rather than passing it through.

Example fix

// before
[ConfigGroup("")]
public class MyFactory : IConfigFactory { }

// after — either omit the attribute or set a real name
public class MyFactory : IConfigFactory { } // falls back to ConfigGroupNames.Config
Defensive patterns

Strategy: validation

Validate before calling

// Defensive: normalize empty group to the default before calling Add
string group = string.IsNullOrWhiteSpace(configGroup) ? ConfigGroupNames.Config : configGroup;
factories.Add(group, factory);

Prevention

When it happens

Trigger: CreateConfigFactories calls Add(GetConfigGroup(factoryType), factory). GetConfigGroup returns the ConfigGroupAttribute.Name; if that attribute exists but its Name is explicitly empty/whitespace (and thus is NOT replaced by the default, because the default only applies when the attribute is null/missing), Add throws.

Common situations: A developer added [ConfigGroup("")] or [ConfigGroup(" ")] to a factory thinking it means 'default'; a codegen template emitted an empty Name.

Related errors


AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13). Data as JSON: /api/errors/7db2969886e18118. Report an issue: GitHub.