egametang/ET · error · Exception

condition node params field must be string[]: {node.GetType(

Error message

condition node params field must be string[]: {node.GetType().FullName}.Params

What it means

Thrown by SetParamsField when the `Params` field exists but its element type is not exactly `string[]` (e.g. declared as `object[]`, `int[]`, or `List<string>`). The parser hands in a string array of raw argument tokens, so a mismatched element type is rejected rather than coerced.

Source

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

            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");
            }

            fieldInfo.SetValue(node, paramValues);
        }

        private void AddSequenceChild(BTSequence sequence, BTNode child)
        {
            if (child is BTSequence childSequence)
            {
                sequence.Children.AddRange(childSequence.Children);
                return;
            }

            sequence.Children.Add(child);
        }

        private void AddSelectorChild(BTSelector selector, BTNode child)
        {

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Declare the field as `public string[] Params;` and parse element values inside the node's execution.
  2. Keep typed conversion logic in the node; the parser only carries raw string tokens.

Example fix

// before
public int[] Params;
// after
public string[] Params;
Defensive patterns

Strategy: type-guard

Type guard

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

Prevention

When it happens

Trigger: Declaring `public object[] Params;` or `public List<string> Params;` on a node and then using the `NodeName(a, b)` parameter syntax.

Common situations: Author wants typed parameters and tries `int[] Params` expecting auto-conversion; refactor changes the collection type from array to List.

Related errors


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