babalae/better-genshin-impact · error · InvalidOperationException
角色 {CurrentTarget.Name} 缺少武器筛选类型。
Error message
角色 {CurrentTarget.Name} 缺少武器筛选类型。 What it means
In the `FilterPanel` state handler, the task needs a weapon-type filter string to apply. `_pendingWeaponType` is derived in `PrepareCharacter` via `GetFilterTypes`, which falls back from the target's forced weapon type to `recognizer.GetWeaponType(...)`. If that yields null/whitespace (character absent from the avatar prototype table), applying the weapon filter is impossible and the handler throws `InvalidOperationException`.
Source
Thrown at BetterGenshinImpact/GameTask/CharacterDevelopment/CharacterDevelopmentTask.cs:584
}
_workflowState = CharacterDevelopmentState.FilterPanel;
return Task.FromResult(StateHandlerResult.Success);
}
[StateHandler(CharacterDevelopmentState.FilterPanel, RetryTimeout = 12000, RetryInterval = 300, TransitionTimeout = 5000)]
private Task<StateHandlerResult> HandleFilterPanel(BvPage page)
{
using var capture = CaptureToRectArea();
if (CharacterSelectionHelper.IsFilterApplied(capture, _assetScale))
{
CharacterSelectionHelper.ClearFilter(page, _assetScale, _logger);
return Task.FromResult(StateHandlerResult.Wait);
}
if (string.IsNullOrWhiteSpace(_pendingWeaponType))
{
throw new InvalidOperationException($"角色 {CurrentTarget.Name} 缺少武器筛选类型。");
}
_workflowState = string.IsNullOrWhiteSpace(_pendingElementType)
? CharacterDevelopmentState.SelectWeaponFilter
: CharacterDevelopmentState.SelectElementFilter;
return Task.FromResult(StateHandlerResult.Success);
}
[StateHandler(CharacterDevelopmentState.SelectElementFilter, RetryTimeout = 12000, RetryInterval = 300, TransitionTimeout = 3000)]
private Task<StateHandlerResult> HandleSelectElementFilter(BvPage page)
{
if (string.IsNullOrWhiteSpace(_pendingElementType))
{
_workflowState = CharacterDevelopmentState.SelectWeaponFilter;
return Task.FromResult(StateHandlerResult.Success);
}
using var capture = CaptureToRectArea();View on GitHub (pinned to a7cb36712d)
Solutions
- Update the avatar prototype table/config so the character resolves to a known weapon type.
- Provide the character under a name that maps to a configured avatar (use the configured alias).
- For custom display-name characters, supply a `CharacterSelectionTarget` with `ForcedWeaponType` set so the fallback is unnecessary.
Example fix
// before: unknown character → GetWeaponType returns null new CharacterDevelopmentStateMachineTask(["新角色未入表"], cats); // after: force the weapon type via a custom target, or add the avatar mapping
Defensive patterns
Strategy: validation
Validate before calling
var (_, weapon) = CharacterSelectionHelper.GetFilterTypes(target, recognizer);
if (string.IsNullOrWhiteSpace(weapon))
throw new InvalidOperationException($"角色 {target.Name} 无可用武器筛选类型,请更新头像原型表。"); Try / catch
try { await task.Start(ct); }
catch (InvalidOperationException ex) when (ex.Message.Contains("缺少武器筛选类型"))
{ /* log and prompt user to update avatar prototype table / use a known name */ } Prevention
- Keep the avatar prototype table updated for newly released characters.
- Use configured/standard avatar names or aliases so GetWeaponType resolves.
- For custom display-name characters, supply ForcedWeaponType on the target.
When it happens
Trigger: A character name whose standard form is not in the avatar prototype table (so `GetWeaponType` returns null/empty), combined with no element filter being pending; custom/奇偶 characters without a forced weapon type; a stale or incomplete avatar map after a game version update.
Common situations: Newly released character not yet added to the prototype table; misspelled/aliased name that resolves to an unknown avatar; modded/custom display-name character.
Related errors
- 未找到目标角色 {CurrentTarget.Name}。
- 角色养成识别:头像识别器尚未初始化。
- 角色养成识别:当前角色尚未初始化。
- 角色养成识别:当前结果尚未初始化。
- 无法读取分类 {_currentCategory}。
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/7a734bac888c79eb.
Report an issue: GitHub.