egametang/ET · error

config create failed: {configType.FullName}

Error message

config create failed: {configType.FullName}

What it means

Thrown by LoadOneConfig when IConfigFactory.Create() returns null. The factory was found and resolved (GetConfigFactory succeeded) but its Create method produced no category object. This indicates the factory's Create logic deliberately or accidentally returned null — e.g. it tried to load backing data that wasn't present.

Source

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

                factories.Add(GetConfigGroup(factoryType), factory);
            }

            return factories;
        }

        public static ASingleton LoadOneConfig(Type configType, ConfigFactoryGroupCollection configFactories, Dictionary<Type, IConfig> loadedConfigs)
        {
            ConfigProcessAttribute configProcessAttribute = configType.GetCustomAttributes(typeof(ConfigProcessAttribute), false)[0] as ConfigProcessAttribute;
            if (configProcessAttribute.ConfigType != ConfigType.Code)
            {
                throw new Exception($"unsupported config type: {configProcessAttribute.ConfigType} {configType.FullName}");
            }

            IConfigFactory factory = GetConfigFactory(configType, configFactories);
            object category = factory.Create();
            if (category == null)
            {
                throw new Exception($"config create failed: {configType.FullName}");
            }

            if (category.GetType() != configType)
            {
                throw new Exception($"config type mismatch: expect={configType.FullName} actual={category.GetType().FullName}");
            }

            if (category is not ASingleton singleton)
            {
                throw new Exception($"config singleton invalid: {configType.FullName}");
            }

            if (category is not IConfig iConfig)
            {
                throw new Exception($"config interface invalid: {configType.FullName}");
            }

            loadedConfigs.Add(configType, iConfig);

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Regenerate the config data (Luban/codegen) and ensure the output is included in the assembly/build.
  2. Inspect the named factory's Create() to see why it returns null and fix or surface the underlying load error.
  3. Verify embedded resources/assets for that config are present at runtime.

Example fix

// before — factory returns null silently when data missing
public object Create()
{
    var data = LoadEmbedded(Name);
    if (data == null) return null;
    return new MyCategory(data);
}

// after — surface the real cause
public object Create()
{
    var data = LoadEmbedded(Name)
        ?? throw new Exception($"missing config data for {Name}");
    return new MyCategory(data);
}
Defensive patterns

Strategy: try-catch

Try / catch

try { singleton = ConfigLoaderHelper.LoadOneConfig(t, factories, loaded); }
catch (Exception e) when (e.Message.Contains("config create failed"))
{ Log.Error($"factory for {t.FullName} returned null; check its backing data"); throw; }

Prevention

When it happens

Trigger: GetConfigFactory returned a valid factory, but factory.Create() returns null. Common when Create reads an embedded resource/asset that is missing or empty and the factory returns null instead of throwing.

Common situations: The config's backing data file/embedded resource was not generated or not included in the build; a codegen step produced the factory but not its data; a config that depends on another config that failed to load.

Related errors


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