babalae/better-genshin-impact · error · ArgumentException
未知的前置 action 类型
Error message
未知的前置 action 类型
What it means
Thrown by ActionFactory.GetBeforeHandler when the supplied action string is neither 'up_down_grab_leaf' nor 'stop_flying' — the only two registered before-action (前置 action) handlers.
Source
Thrown at BetterGenshinImpact/GameTask/AutoPathing/Handler/ActionFactory.cs:49
"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
- Correct the before_action value to 'up_down_grab_leaf' or 'stop_flying'.
- Remove the unsupported before-action from the waypoint if it isn't needed.
- Update to a build that supports the action if it is a legitimate new type.
Example fix
// before
var handler = ActionFactory.GetBeforeHandler(beforeAction);
// after
var knownBefore = new[]{"up_down_grab_leaf","stop_flying"};
if (!knownBefore.Contains(beforeAction))
{
throw new ArgumentException($"未知的前置 action 类型: {beforeAction}. 支持的值: {string.Join(", ", knownBefore)}");
} Defensive patterns
Strategy: validation
Validate before calling
var knownBefore = new[]{"up_down_grab_leaf","stop_flying"};
if (!knownBefore.Contains(beforeAction))
{
throw new ArgumentException($"未知的前置 action 类型: {beforeAction}");
} Type guard
static readonly HashSet<string> KnownBeforeActions = new(){"up_down_grab_leaf","stop_flying"};
bool IsValidBeforeAction(string? a) => a is not null && KnownBeforeActions.Contains(a); Prevention
- Validate before_action values when loading pathing tasks.
- Keep the known set in sync with ActionFactory registrations.
- Use an authoring tool that restricts before-action choices.
When it happens
Trigger: A pathing-task waypoint defines a before-action with a value outside {up_down_grab_leaf, stop_flying}, and GetBeforeHandler is called with it.
Common situations: Typo in the JSON before_action field; an unsupported before-action was authored; the before-action set was reduced in this build.
Related errors
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/1eb5a551ea839959.
Report an issue: GitHub.