babalae/better-genshin-impact · error · ArgumentException

AutoSkip的配置参数需要为AutoSkipConfig类型

Error message

AutoSkip的配置参数需要为AutoSkipConfig类型

What it means

Thrown by the RealtimeTimer constructor when Name equals "AutoSkip" but the provided config object is not of type AutoSkipConfig. Unlike AutoPick (which auto-converts via ScriptObjectConverter), AutoSkip requires the caller to pass an already-typed AutoSkipConfig instance — no conversion is attempted.

Source

Thrown at BetterGenshinImpact/Core/Script/Dependence/Model/RealTimeTimer.cs:53

        Name = name;
    }

    public RealtimeTimer(string name, dynamic config)
    {
        Name = name;
        if (Name == "AutoPick")
        {
            Config = ScriptObjectConverter.ConvertTo<AutoPickExternalConfig>(config);
        }
        else if (Name == "AutoSkip")
        {
            if (config is AutoSkipConfig)
            {
                Config = config;
            }
            else 
            {
                throw new ArgumentException("AutoSkip的配置参数需要为AutoSkipConfig类型");
            }
        }
    }
}

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Pre-convert the config: pass ScriptObjectConverter.ConvertTo<AutoSkipConfig>(config) into the constructor.
  2. Ensure your JSON deserialization uses typed settings that map the AutoSkip config field to AutoSkipConfig.
  3. If building programmatically, construct new AutoSkipConfig() and populate its properties directly.

Example fix

// before
var timer = new RealtimeTimer("AutoSkip", jObject);
// after
var cfg = ScriptObjectConverter.ConvertTo<AutoSkipConfig>(jObject);
var timer = new RealtimeTimer("AutoSkip", cfg);
Defensive patterns

Strategy: type-guard

Validate before calling

if (name == "AutoSkip")
{
    var typedConfig = config is AutoSkipConfig existing
        ? existing
        : ScriptObjectConverter.ConvertTo<AutoSkipConfig>(config);
    var timer = new RealtimeTimer(name, typedConfig);
}

Type guard

static bool IsValidAutoSkipConfig(object config) => config is AutoSkipConfig;

Try / catch

try
{
    var timer = new RealtimeTimer("AutoSkip", config);
}
catch (ArgumentException ex) when (ex.Message.Contains("AutoSkip"))
{
    // Convert and retry
    var converted = ScriptObjectConverter.ConvertTo<AutoSkipConfig>(config);
    var timer = new RealtimeTimer("AutoSkip", converted);
}

Prevention

When it happens

Trigger: Constructing new RealtimeTimer("AutoSkip", config) where config is a JObject, ExpandoObject, anonymous type, or any type other than AutoSkipConfig. The check is a strict 'is AutoSkipConfig' type test.

Common situations: Deserializing a timer configuration from JSON where the config field is parsed as a generic object/JObject rather than a typed AutoSkipConfig. Migrating from a dynamic config model to typed configs without updating the serialization path.

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/c6ef76b951684f2e. Report an issue: GitHub.