egametang/ET · critical · Exception

condition variable is empty: {type.FullName}

Error message

condition variable is empty: {type.FullName}

What it means

Thrown during ConditionVariableRegistry.Awake() when a [ConditionVariable] attribute on a scanned type has a null, empty, or whitespace Variable string. The variable name is the lookup key for the parser, so an empty one is unusable.

Source

Thrown at Packages/cn.etetet.conditionexpr/Scripts/Model/Share/ConditionVariableRegistry.cs:31

        public void Awake()
        {
            this.RegisterNumericTypes();
            
            HashSet<Type> types = CodeTypes.Instance.GetTypes(typeof(ConditionVariableAttribute));
            foreach (Type type in types)
            {
                if (!typeof(BTCondition).IsAssignableFrom(type))
                {
                    throw new Exception($"condition variable node must inherit BTCondition: {type.FullName}");
                }

                object[] attrs = type.GetCustomAttributes(typeof(ConditionVariableAttribute), false);
                foreach (object attr in attrs)
                {
                    ConditionVariableAttribute conditionVariableAttribute = (ConditionVariableAttribute)attr;
                    if (string.IsNullOrWhiteSpace(conditionVariableAttribute.Variable))
                    {
                        throw new Exception($"condition variable is empty: {type.FullName}");
                    }

                    if (!this.variableNodeTypes.TryAdd(conditionVariableAttribute.Variable, type))
                    {
                        throw new Exception($"duplicate condition variable: {conditionVariableAttribute.Variable}");
                    }
                }
            }
        }

        private void RegisterNumericTypes()
        {
            foreach (NumericType numericType in Enum.GetValues(typeof(NumericType)))
            {
                string variable = numericType.ToString();
                this.numericTypes.Add(variable, numericType);
                this.variableNodeTypes.Add(variable, typeof(BTNumericCompare));
            }

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Set a non-empty, trimmed Variable string on the attribute, e.g. `[ConditionVariable("HasBuff")]`.
  2. Add a unit test asserting every [ConditionVariable] in the assembly has a non-empty name.

Example fix

// before
[ConditionVariable("")]
public class HasBuffNode : BTCondition { }
// after
[ConditionVariable("HasBuff")]
public class HasBuffNode : BTCondition { }
Defensive patterns

Strategy: validation

Validate before calling

foreach (Type t in CodeTypes.Instance.GetTypes(typeof(ConditionVariableAttribute)))
{
    foreach (ConditionVariableAttribute a in t.GetCustomAttributes(typeof(ConditionVariableAttribute), false))
        Assert.IsFalse(string.IsNullOrWhiteSpace(a.Variable), $"{t.FullName} has empty variable");
}

Prevention

When it happens

Trigger: Writing `[ConditionVariable("")]` or `[ConditionVariable(" ")]`, or using the attribute's default constructor/field that leaves Variable unset.

Common situations: Typo when filling the attribute; copy-paste of a template with a placeholder; attribute refactored to take the name from another property that returns empty.

Related errors


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