{"record":{"id":"cc6b742dbf91d3ad","repo":"babalae/better-genshin-impact","slug":"error-cc6b74","errorCode":null,"errorMessage":"战斗任务参数不能为空","messagePattern":"战斗任务参数不能为空","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/Core/Script/Dependence/Dispatcher.cs","lineNumber":370,"sourceCode":"        {\n            throw new ArgumentNullException(nameof(param), \"自动首领讨伐任务参数不能为空\");\n        }\n\n        CancellationToken cancellationToken = customCt ?? CancellationContext.Instance.Cts.Token;\n        return await new AutoBossTask(param).Start(cancellationToken);\n    }\n\n    /// <summary>  \n    /// 运行自动战斗任务\n    /// </summary>  \n    /// <param name=\"param\">战斗任务参数</param>  \n    /// <param name=\"customCt\">自定义取消令牌</param>  \n    /// <returns></returns>  \n    public async Task RunAutoFightTask(AutoFightParam param, CancellationToken? customCt = null)  \n    {  \n        if (param == null)  \n        {  \n            throw new ArgumentNullException(nameof(param), \"战斗任务参数不能为空\");  \n        }  \n  \n        CancellationToken cancellationToken = customCt ?? CancellationContext.Instance.Cts.Token;  \n        var factory = GameTask.AutoFight.Factory.CombatTaskFactoryProvider.GetFactory(param.CombatStrategyPath);\n        var fightTask = factory.CreateTask(param);\n        await fightTask.Start(cancellationToken);  \n    }\n    \n    /// <summary>\n    /// 运行简易战斗策略脚本。\n    /// 使用策略语言直接控制角色执行动作（如 e、q、attack 等），适合快速操作。\n    /// </summary>\n    /// <param name=\"script\">策略字符串，支持逗号/换行/分号分隔指令，可选角色名前缀</param>\n    /// <param name=\"avatarName\">指定操作的角色名（可选，不指定则操作当前角色）</param>\n    /// <param name=\"customCt\">自定义取消令牌</param>\n    public async Task RunCombatScript(string script, string? avatarName = null, CancellationToken? customCt = null)\n    {\n        if (string.IsNullOrWhiteSpace(script))","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Core/Script/Dependence/Dispatcher.cs#L352-L388","documentation":"ArgumentNullException thrown by RunAutoFightTask at line 370 when the AutoFightParam argument is null. AutoFightParam carries CombatStrategyPath which is immediately used (line 374) to resolve a combat task factory — a null param would NPE one line later anyway, so the guard fails fast with a clear message.","triggerScenarios":"JS calls `dispatcher.RunAutoFightTask(null)`. A param built conditionally was never assigned.","commonSituations":"Author forgot to construct AutoFightParam. Combat strategy path not resolved before construction.","solutions":["Construct AutoFightParam with a valid CombatStrategyPath before calling.","Null-check in JS before invoking.","Ensure the strategy file exists so construction does not silently yield null."],"exampleFix":"// before (JS)\ndispatcher.RunAutoFightTask(param); // null -> throws\n\n// after (JS)\nconst fightParam = new AutoFightParam(combatStrategyPath);\ndispatcher.RunAutoFightTask(fightParam);","handlingStrategy":"validation","validationCode":"// JS side\nif (!param) throw new Error('AutoFightParam is required');\ndispatcher.RunAutoFightTask(param);","typeGuard":"// JS\nfunction isAutoFightParam(v) { return v != null && typeof v === 'object' && typeof v.CombatStrategyPath !== 'undefined'; }","tryCatchPattern":null,"preventionTips":["Construct AutoFightParam with a valid CombatStrategyPath before calling.","Ensure the strategy file exists so construction is not null.","Null-check params in JS wrappers."],"tags":["script","argument-null","auto-fight","dispatcher"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}