egametang/ET · error · Exception

condition node owner key field must be string: {node.GetType

Error message

condition node owner key field must be string: {node.GetType().FullName}.{nameof(BTNumericCompare.OwnerKey)}

What it means

Thrown by SetOwnerKeyField after the `OwnerKey` field was found by reflection but its declared type is not exactly `string`. The owner-key value passed in is a string (the part before the dot), so any other field type cannot be assigned and is rejected to avoid a silent type mismatch.

Source

Thrown at Packages/cn.etetet.conditionexpr/Scripts/Model/Share/ConditionExprParser.cs:291

            if (fieldInfo == null)
            {
                throw new Exception($"condition node field not found: {node.GetType().FullName}.{fieldName}");
            }

            fieldInfo.SetValue(node, value);
        }

        private void SetOwnerKeyField(BTCondition node, string ownerKey)
        {
            FieldInfo fieldInfo = node.GetType().GetField(nameof(BTNumericCompare.OwnerKey), BindingFlags.Instance | BindingFlags.Public);
            if (fieldInfo == null)
            {
                throw new Exception($"condition node owner key field not found: {node.GetType().FullName}.{nameof(BTNumericCompare.OwnerKey)}");
            }

            if (fieldInfo.FieldType != typeof(string))
            {
                throw new Exception($"condition node owner key field must be string: {node.GetType().FullName}.{nameof(BTNumericCompare.OwnerKey)}");
            }

            fieldInfo.SetValue(node, ownerKey);
        }

        private void SetParamsField(BTCondition node, string[] paramValues)
        {
            FieldInfo fieldInfo = node.GetType().GetField("Params", BindingFlags.Instance | BindingFlags.Public);
            if (fieldInfo == null)
            {
                throw new Exception($"condition node params field not found: {node.GetType().FullName}.Params");
            }

            if (fieldInfo.FieldType != typeof(string[]))
            {
                throw new Exception($"condition node params field must be string[]: {node.GetType().FullName}.Params");
            }

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Change the field to `public string OwnerKey;` (the canonical contract).
  2. If you need an int id internally, keep `public string OwnerKey;` for the parser and resolve it to an id inside the node's execution.

Example fix

// before
public int OwnerKey;
// after
public string OwnerKey;
Defensive patterns

Strategy: type-guard

Type guard

static bool OwnerKeyIsString(Type t)
{
    var f = t.GetField("OwnerKey", BindingFlags.Instance | BindingFlags.Public);
    return f != null && f.FieldType == typeof(string);
}

Prevention

When it happens

Trigger: Declaring `public int OwnerKey;` or `public Guid OwnerKey;` on a custom condition node and then using the `OwnerKey.Variable` dotted syntax.

Common situations: A developer models the owner as an int id and reuses the canonical name `OwnerKey` for it; type was widened to a custom struct during a refactor.

Related errors


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