egametang/ET · error · Exception

condition root child count error: {node.Children.Count}

Error message

condition root child count error: {node.Children.Count}

What it means

Thrown by ConditionRootHandler.Run when a ConditionRoot node has more than one child. ConditionRoot is the entry node produced by ConditionExprParser and is a structural invariant: it must hold zero or one child expression. More than one means the tree was constructed incorrectly (the parser normally adds exactly one child via ParseExpression, so this indicates manual/external tree assembly or a corrupted node).

Source

Thrown at Packages/cn.etetet.conditionexpr/Scripts/Hotfix/Share/ConditionRootHandler.cs:14

namespace ET
{
    public class ConditionRootHandler : ABTHandler<ConditionRoot>
    {
        protected override int Run(ConditionRoot node, BTEnv env)
        {
            if (node.Children == null || node.Children.Count == 0)
            {
                return ErrorCode.ERR_Success;
            }

            if (node.Children.Count > 1)
            {
                throw new System.Exception($"condition root child count error: {node.Children.Count}");
            }

            return BTDispatcher.Instance.Handle(node.Children[0], env);
        }
    }
}

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Ensure ConditionRoot is only produced by ConditionExprParser.Parse (which adds exactly one child).
  2. If constructing ConditionRoot manually, add at most one child expression.
  3. Audit any serialization/deserialization path that rebuilds ConditionRoot to confirm it does not append extra children.
  4. Do not mutate node.Children after the parser returns.

Example fix

// before (manual construction)
var root = new ConditionRoot();
root.Children.Add(exprA);
root.Children.Add(exprB); // throws [50] at runtime

// after
var root = new ConditionRoot();
root.Children.Add(exprA);
Defensive patterns

Strategy: validation

Validate before calling

if (node.Children != null && node.Children.Count <= 1) { /* safe to handle */ }
// Do not construct ConditionRoot with >1 child; rely on ConditionExprParser.Parse.

Prevention

When it happens

Trigger: A ConditionRoot node whose Children list was populated with 2+ entries, e.g. by manually building the node or by a serializer that injected extra children. The parser only ever adds one child, so this is an external-construction or data-corruption fault.

Common situations: Hand-built or deserialized ConditionRoot with multiple children; a tree editor/serializer that duplicates the child; downstream code that appends to node.Children after parsing.

Related errors


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