babalae/better-genshin-impact · error · ArgumentNullException

自动首领讨伐任务参数不能为空

Error message

自动首领讨伐任务参数不能为空

What it means

ArgumentNullException thrown by RunAutoBossTask at line 353 when the AutoBossParam argument is null. Same pattern as the other RunXxxTask helpers: this entrypoint expects a ready param object carrying boss/strategy configuration.

Source

Thrown at BetterGenshinImpact/Core/Script/Dependence/Dispatcher.cs:353

        {  
            throw new ArgumentNullException(nameof(param), "秘境任务参数不能为空");  
        }  
  
        CancellationToken cancellationToken = customCt ?? CancellationContext.Instance.Cts.Token;  
        return await new AutoDomainTask(param).Start(cancellationToken);
    }  

    /// <summary>
    /// 运行自动首领讨伐任务
    /// </summary>
    /// <param name="param">自动首领讨伐任务参数</param>
    /// <param name="customCt">自定义取消令牌</param>
    /// <returns></returns>
    public async Task<Dictionary<string, int>> RunAutoBossTask(AutoBossParam param, CancellationToken? customCt = null)
    {
        if (param == null)
        {
            throw new ArgumentNullException(nameof(param), "自动首领讨伐任务参数不能为空");
        }

        CancellationToken cancellationToken = customCt ?? CancellationContext.Instance.Cts.Token;
        return await new AutoBossTask(param).Start(cancellationToken);
    }

    /// <summary>  
    /// 运行自动战斗任务
    /// </summary>  
    /// <param name="param">战斗任务参数</param>  
    /// <param name="customCt">自定义取消令牌</param>  
    /// <returns></returns>  
    public async Task RunAutoFightTask(AutoFightParam param, CancellationToken? customCt = null)  
    {  
        if (param == null)  
        {  
            throw new ArgumentNullException(nameof(param), "战斗任务参数不能为空");  
        }  

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Construct AutoBossParam with boss and strategy settings before calling.
  2. Null-check in JS before invoking.

Example fix

// before (JS)
dispatcher.RunAutoBossTask(param); // null -> throws

// after (JS)
const bossParam = new AutoBossParam(strategyPath);
dispatcher.RunAutoBossTask(bossParam);
Defensive patterns

Strategy: validation

Validate before calling

// JS side
if (!param) throw new Error('AutoBossParam is required');
dispatcher.RunAutoBossTask(param);

Type guard

// JS
function isAutoBossParam(v) { return v != null && typeof v === 'object'; }

Prevention

When it happens

Trigger: JS calls `dispatcher.RunAutoBossTask(null)` or passes an undefined variable.

Common situations: Author forgot to build AutoBossParam. Refactor left the param unset.

Related errors


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