{"record":{"id":"164459ae485299b2","repo":"egametang/ET","slug":"condition-root-child-count-error-node-children-c","errorCode":null,"errorMessage":"condition root child count error: {node.Children.Count}","messagePattern":"condition root child count error: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.conditionexpr/Scripts/Hotfix/Share/ConditionRootHandler.cs","lineNumber":14,"sourceCode":"namespace ET\n{\n    public class ConditionRootHandler : ABTHandler<ConditionRoot>\n    {\n        protected override int Run(ConditionRoot node, BTEnv env)\n        {\n            if (node.Children == null || node.Children.Count == 0)\n            {\n                return ErrorCode.ERR_Success;\n            }\n\n            if (node.Children.Count > 1)\n            {\n                throw new System.Exception($\"condition root child count error: {node.Children.Count}\");\n            }\n\n            return BTDispatcher.Instance.Handle(node.Children[0], env);\n        }\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":21,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.conditionexpr/Scripts/Hotfix/Share/ConditionRootHandler.cs#L1-L21","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure ConditionRoot is only produced by ConditionExprParser.Parse (which adds exactly one child).","If constructing ConditionRoot manually, add at most one child expression.","Audit any serialization/deserialization path that rebuilds ConditionRoot to confirm it does not append extra children.","Do not mutate node.Children after the parser returns."],"exampleFix":"// before (manual construction)\nvar root = new ConditionRoot();\nroot.Children.Add(exprA);\nroot.Children.Add(exprB); // throws [50] at runtime\n\n// after\nvar root = new ConditionRoot();\nroot.Children.Add(exprA);","handlingStrategy":"validation","validationCode":"if (node.Children != null && node.Children.Count <= 1) { /* safe to handle */ }\n// Do not construct ConditionRoot with >1 child; rely on ConditionExprParser.Parse.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only obtain ConditionRoot from the parser, which guarantees one child.","Never append to ConditionRoot.Children after construction.","Audit serializers/deserializers that rebuild ConditionRoot."],"tags":["conditionexpr","behaviortree","structural-invariant","csharp","unity","runtime"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}