babalae/better-genshin-impact · error · InvalidDataException
物品原型表中没有 item_class_id 以 weapon: 开头的武器记录。
Error message
物品原型表中没有 item_class_id 以 weapon: 开头的武器记录。
What it means
Thrown by ExtractWeaponNames after iterating all rows when no entry had an item_class_id starting with 'weapon:'. The matcher relies entirely on this filtered set; without weapon records it cannot perform any name correction. This signals the item.csv is the wrong file, an outdated version, or a different-language export that uses a different class-id scheme.
Source
Thrown at BetterGenshinImpact/GameTask/CharacterDevelopment/WeaponNameMatcher.cs:115
{
throw new InvalidDataException("物品原型表存在列数不足的记录。");
}
if (!columns[itemClassIdIndex].Trim().StartsWith("weapon:", StringComparison.OrdinalIgnoreCase))
{
continue;
}
var name = columns[itemNameIndex].Trim();
if (!string.IsNullOrWhiteSpace(name))
{
names.Add(name);
}
}
if (names.Count == 0)
{
throw new InvalidDataException("物品原型表中没有 item_class_id 以 weapon: 开头的武器记录。");
}
return names.OrderBy(name => name, StringComparer.Ordinal).ToArray();
}
/// <summary>
/// 计算两个字符串的 Levenshtein 编辑距离。
/// </summary>
/// <remarks>仅保留两行动态规划状态,额外空间复杂度为 O(min(m,n))。</remarks>
internal static int LevenshteinDistance(string source, string target)
{
if (source.Length == 0)
{
return target.Length;
}
if (target.Length == 0)
{View on GitHub (pinned to a7cb36712d)
Solutions
- Verify the item.csv at Assets/Model/ItemV2/ is the original bundled file that includes weapon rows.
- Check that item_class_id values in the CSV actually contain entries prefixed with 'weapon:'.
- Restore the asset from a known-good release of the project.
Example fix
null
Defensive patterns
Strategy: validation
Validate before calling
var hasWeaponRows = rows.Any(r => r[itemClassIdIndex].Trim().StartsWith("weapon:", StringComparison.OrdinalIgnoreCase));
if (!hasWeaponRows) { /* abort: wrong CSV */ } Type guard
null
Try / catch
try { var names = ExtractWeaponNames(headers, rows); }
catch (InvalidDataException) { /* no weapon data — restore correct item.csv */ } Prevention
- Confirm item.csv is the original project asset that includes weapon: entries.
- Run a data-integrity smoke test after any asset update.
When it happens
Trigger: item.csv loads and parses correctly but every row's item_class_id starts with a non-weapon prefix (e.g., 'material:', 'food:'), or the column value format changed in a game data update.
Common situations: Using a custom or community-curated item.csv that omits weapons. A Genshin Impact data version change altered the item_class_id naming convention. The wrong CSV was placed at Assets/Model/ItemV2/item.csv.
Related errors
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/79d13289a770817b.
Report an issue: GitHub.