babalae/better-genshin-impact · error · ArgumentException

未知的任务名称: {soloTask.Name}

Error message

未知的任务名称: {soloTask.Name}

What it means

ArgumentException thrown at line 310 in the default branch of the RunTask switch. soloTask.Name did not match any cased task name (AutoGeniusInvokation, AutoWood, AutoFight, AutoDomain, AutoBoss, AutoFishing, AutoCook, AutoEat, CountInventoryItem). The name is matched as an exact, case-sensitive string literal.

Source

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

                    var result = await new CountInventoryItem(param).Start(cancellationToken);
                    if (param.ItemName != null)
                    {
                        return result;
                    }
                    else
                    {
                        dynamic expando = new ExpandoObject();
                        var expandoDict = (IDictionary<string, object>)expando;
                        foreach (var kvp in (Dictionary<string, int>)result)
                        {
                            expandoDict[kvp.Key] = kvp.Value;
                        }
                        return expandoDict;
                    }
                }
            default:
                throw new ArgumentException($"未知的任务名称: {soloTask.Name}", nameof(soloTask.Name));
        }
    }

    public CancellationTokenSource GetLinkedCancellationTokenSource()
    {
        // 创建一个新的链接令牌源,链接到全局令牌
        return CancellationTokenSource.CreateLinkedTokenSource(CancellationContext.Instance.Cts.Token);
    }


    public CancellationToken GetLinkedCancellationToken()
    {
        return GetLinkedCancellationTokenSource().Token;
    }
    
    /// <summary>  
    /// 运行自动秘境任务
    /// </summary>  

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Use an exact task name from the supported list (AutoGeniusInvokation, AutoWood, AutoFight, AutoDomain, AutoBoss, AutoFishing, AutoCook, AutoEat, CountInventoryItem).
  2. Trim and verify the name in JS before constructing the SoloTask.
  3. Maintain a constant list of valid names in your script to avoid typos.

Example fix

// before (JS)
dispatcher.RunTask(new SoloTask('AutoDomain ')); // trailing space -> default -> throws

// after (JS)
dispatcher.RunTask(new SoloTask('AutoDomain')); // exact match
Defensive patterns

Strategy: validation

Validate before calling

// JS side
const VALID_TASKS = ['AutoGeniusInvokation','AutoWood','AutoFight','AutoDomain','AutoBoss','AutoFishing','AutoCook','AutoEat','CountInventoryItem'];
if (!VALID_TASKS.includes(name)) throw new Error(`Unknown task name: ${name}`);

Prevention

When it happens

Trigger: JS constructs `new SoloTask('AutoDomain ')` (trailing space), `new SoloTask('autodomain')` (wrong case), or `new SoloTask('AutoMine')` (nonexistent task).

Common situations: Typo or casing error. Using a task name from a different version. Trailing whitespace from string concatenation in JS.

Related errors


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