egametang/ET · error · Exception
bt node is null
Error message
bt node is null
What it means
BTDispatcher.Handle was called with a null BTNode argument. Handle is the single dispatch entry point and requires a non-null node to look up and execute the corresponding handler. A null node is a programming error in the caller — typically a tree-traversal or deserialization bug.
Source
Thrown at Packages/cn.etetet.behaviortree/Scripts/Model/Share/BTDispatcher.cs:60
{
object obj = Activator.CreateInstance(type);
IBTHandler ibtHandler = obj as IBTHandler;
if (ibtHandler == null)
{
throw new Exception($"bt handler not inherit IMActorHandler abstract class: {obj.GetType().FullName}");
}
Type nodeType = ibtHandler.GetNodeType();
this.btHandlers.Add(nodeType, ibtHandler);
}
public int Handle(BTNode node, BTEnv env)
{
if (node == null)
{
throw new Exception($"bt node is null");
}
if (!this.btHandlers.TryGetValue(node.GetType(), out IBTHandler ibtHandler))
{
throw new Exception($"not found bt handler: {node.GetType().FullName}");
}
int ret = ibtHandler.Handle(node, env);
#if UNITY_EDITOR
env.AddSnapshot($"Node {node.GetType().Name} {node.Id} return {ret}");
#endif
return ret;
}
}
}
View on GitHub (pinned to 5cab01f7a8)
Solutions
- Add a null check for node before calling Handle and return an appropriate default (e.g., BTResult.Failure).
- Trace where the null node originates — inspect the tree-building, deserialization, or traversal code.
- Ensure all BTNode references in the tree are assigned during construction.
Example fix
// before
int ret = BTDispatcher.Instance.Handle(node, env); // crashes if node is null
// after
if (node == null)
{
return BTResult.Failure;
}
int ret = BTDispatcher.Instance.Handle(node, env); Defensive patterns
Strategy: validation
Validate before calling
// Validate node is non-null before dispatching:
if (node == null)
{
Log.Warning("BTDispatcher.Handle called with null node, skipping");
return BTResult.Failure; // or appropriate default
}
int ret = BTDispatcher.Instance.Handle(node, env); Prevention
- Always null-check BTNode before calling Handle.
- Ensure all BTNode references are assigned during tree construction.
- Trace null nodes to their origin in tree-building or deserialization code.
- Return a safe default (BTResult.Failure) for null nodes rather than crashing.
When it happens
Trigger: Calling BTDispatcher.Instance.Handle(null, env) directly, or passing a BTNode field/reference that was never assigned (null due to missing initialization, failed deserialization, or a conditional that should have skipped dispatch).
Common situations: A BTNode field was never initialized in the tree. A deserialization or tree-building step produced null. A parent node's child reference is null. A conditional that should have prevented the Handle call didn't check.
Related errors
- ERR_LocationLockNotFound
- not found bt handler: {node.GetType().FullName}
- bt handler not inherit IMActorHandler abstract class: {obj.G
AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13).
Data as JSON: /api/errors/8bfd8eb0d5c34592.
Report an issue: GitHub.