babalae/better-genshin-impact · error · ArgumentException
未知的后置 action 类型
Error message
未知的后置 action 类型
What it means
Thrown by ActionFactory.GetAfterHandler when the supplied action string doesn't match any known after-action (后置 action) handler. The switch covers nahida_collect, pick_around, fight, normal_attack, elemental_skill, hydro/electro/anemo/pyro_collect, combat_script, mining, linnea_mining, fishing, exit_and_relogin, wonderland_cycle, set_time, use_gadget, pick_up_collect; anything else hits the default.
Source
Thrown at BetterGenshinImpact/GameTask/AutoPathing/Handler/ActionFactory.cs:36
"nahida_collect" => new NahidaCollectHandler(),
"pick_around" => new PickAroundHandler(),
"fight" => new AutoFightHandler(),
"normal_attack" => new NormalAttackHandler(),
"elemental_skill" => new ElementalSkillHandler(),
"hydro_collect" => new ElementalCollectHandler(ElementalType.Hydro),
"electro_collect" => new ElementalCollectHandler(ElementalType.Electro),
"anemo_collect" => new ElementalCollectHandler(ElementalType.Anemo),
"pyro_collect" => new ElementalCollectHandler(ElementalType.Pyro),
"combat_script" => new CombatScriptHandler(),
"mining" => new MiningHandler(),
"linnea_mining" => new LinneaMiningHandler(),
"fishing" => new FishingHandler(),
"exit_and_relogin" => new ExitAndReloginHandler(),
"wonderland_cycle" => new EnterAndExitWonderlandHandler(),
"set_time" => new SetTimeHandler(),
"use_gadget" => new UseGadgetHandler(),
"pick_up_collect" => new PickUpCollectHandler(),
_ => throw new ArgumentException("未知的后置 action 类型")
};
});
}
public static IActionHandler GetBeforeHandler(string handlerType)
{
return _handlers.GetOrAdd(handlerType, (key) =>
{
return key switch
{
"up_down_grab_leaf" => new UpDownGrabLeafHandler(),
"stop_flying" => new StopFlyingHandler(),
_ => throw new ArgumentException("未知的前置 action 类型")
};
});
}
}
View on GitHub (pinned to a7cb36712d)
Solutions
- Check the waypoint JSON and correct the action value to one of the supported after-action names.
- Update BetterGI to a version that supports the action type if it is a legitimate new action.
- Replace the unsupported action with the closest supported equivalent (e.g. pick_up_collect).
Example fix
// before
var handler = ActionFactory.GetAfterHandler(actionName); // throws on unknown
// after — validate against the known set first
var knownAfter = new[]{"nahida_collect","pick_around","fight","normal_attack","elemental_skill","hydro_collect","electro_collect","anemo_collect","pyro_collect","combat_script","mining","linnea_mining","fishing","exit_and_relogin","wonderland_cycle","set_time","use_gadget","pick_up_collect"};
if (!knownAfter.Contains(actionName))
{
throw new ArgumentException($"未知的后置 action 类型: {actionName}. 支持的值: {string.Join(", ", knownAfter)}");
} Defensive patterns
Strategy: validation
Validate before calling
var knownAfter = new[]{"nahida_collect","pick_around","fight","normal_attack","elemental_skill","hydro_collect","electro_collect","anemo_collect","pyro_collect","combat_script","mining","linnea_mining","fishing","exit_and_relogin","wonderland_cycle","set_time","use_gadget","pick_up_collect"};
if (!knownAfter.Contains(actionName))
{
throw new ArgumentException($"未知的后置 action 类型: {actionName}");
} Type guard
static readonly HashSet<string> KnownAfterActions = new(){"nahida_collect","pick_around","fight","normal_attack","elemental_skill","hydro_collect","electro_collect","anemo_collect","pyro_collect","combat_script","mining","linnea_mining","fishing","exit_and_relogin","wonderland_cycle","set_time","use_gadget","pick_up_collect"};
bool IsValidAfterAction(string? a) => a is not null && KnownAfterActions.Contains(a); Prevention
- Validate waypoint action values against the known set when loading a pathing task.
- Update the known-set list when upgrading to a build with new action types.
- Author pathing tasks with a tool that only offers supported action names.
When it happens
Trigger: A pathing-task waypoint defines an `action` field with a value not in the known after-handler set, and GetAfterHandler is called with it.
Common situations: Typo in the JSON action field; a waypoint uses a newer action name unsupported by this build; schema drift between the task authoring tool and the runtime.
Related errors
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/337425e95d5b52e2.
Report an issue: GitHub.