{"record":{"id":"1433ae4bc2e1f3ad","repo":"egametang/ET","slug":"condition-node-owner-key-field-not-found-node-ge","errorCode":null,"errorMessage":"condition node owner key field not found: {node.GetType().FullName}.{nameof(BTNumericCompare.OwnerKey)}","messagePattern":"condition node owner key field not found: (.+?)\\.(.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.conditionexpr/Scripts/Model/Share/ConditionExprParser.cs","lineNumber":286,"sourceCode":"        }\n\n        private void SetCompareField(BTCondition node, string fieldName, object value)\n        {\n            FieldInfo fieldInfo = node.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public);\n            if (fieldInfo == null)\n            {\n                throw new Exception($\"condition node field not found: {node.GetType().FullName}.{fieldName}\");\n            }\n\n            fieldInfo.SetValue(node, value);\n        }\n\n        private void SetOwnerKeyField(BTCondition node, string ownerKey)\n        {\n            FieldInfo fieldInfo = node.GetType().GetField(nameof(BTNumericCompare.OwnerKey), BindingFlags.Instance | BindingFlags.Public);\n            if (fieldInfo == null)\n            {\n                throw new Exception($\"condition node owner key field not found: {node.GetType().FullName}.{nameof(BTNumericCompare.OwnerKey)}\");\n            }\n\n            if (fieldInfo.FieldType != typeof(string))\n            {\n                throw new Exception($\"condition node owner key field must be string: {node.GetType().FullName}.{nameof(BTNumericCompare.OwnerKey)}\");\n            }\n\n            fieldInfo.SetValue(node, ownerKey);\n        }\n\n        private void SetParamsField(BTCondition node, string[] paramValues)\n        {\n            FieldInfo fieldInfo = node.GetType().GetField(\"Params\", BindingFlags.Instance | BindingFlags.Public);\n            if (fieldInfo == null)\n            {\n                throw new Exception($\"condition node params field not found: {node.GetType().FullName}.Params\");\n            }\n","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.conditionexpr/Scripts/Model/Share/ConditionExprParser.cs#L268-L304","documentation":"Thrown by SetOwnerKeyField when the parser encountered the `OwnerKey.Variable` dotted syntax (e.g. `Unit1.HP > 0`) and the selected condition node has no public instance field named `OwnerKey`. The OwnerKey mechanism is what tells the runtime which entity the variable reads from, so its absence is fatal.","triggerScenarios":"Using a `OwnerKey.Variable` reference against a custom [ConditionVariable] node that does not declare `public string OwnerKey`. Per AGENTS.md, OwnerKey must be a public string field on the node; using the dotted form with a node that lacks it triggers this.","commonSituations":"Reusing a numeric compare style for a non-numeric custom node and forgetting the OwnerKey field; renaming the field to `Owner`/`Target`; adding a new variable node but only testing the bare-variable form (`HP > 0`) which skips SetOwnerKeyField.","solutions":["Add `public string OwnerKey;` to the custom node class.","Ensure the entity whose key you write (e.g. `Unit1`) was registered via BTEnv.AddEntity(key, owner) at the call site.","If the node never needs an owner, only ever reference it in the bare-variable form (no dot) so the parser does not call SetOwnerKeyField."],"exampleFix":"// before\n[ConditionVariable(\"HasBuff\")]\npublic class HasBuffNode : BTCondition { /* no OwnerKey */ }\n// used as:  Tank.HasBuff > 0\n// after\n[ConditionVariable(\"HasBuff\")]\npublic class HasBuffNode : BTCondition\n{\n    public string OwnerKey;\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static bool HasOwnerKeyField(Type t) =>\n    t.GetField(\"OwnerKey\", BindingFlags.Instance | BindingFlags.Public) != null;","tryCatchPattern":null,"preventionTips":["Standardize a base class for custom condition nodes that includes `public string OwnerKey;`.","Test nodes against both bare and dotted variable syntax.","Add a compile-time/test-time scan ensuring OwnerKey exists on any node used with dotted references."],"tags":["csharp","unity","conditionexpr","reflection","attribute"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}