{"record":{"id":"135d126d4f8e5268","repo":"babalae/better-genshin-impact","slug":"error-135d12","errorCode":null,"errorMessage":"物品原型表存在列数不足的记录。","messagePattern":"物品原型表存在列数不足的记录。","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/CharacterDevelopment/WeaponNameMatcher.cs","lineNumber":98,"sourceCode":"    }\n\n    /// <summary>\n    /// 从物品原型表中提取并去重标准武器名称。\n    /// </summary>\n    internal static IReadOnlyList<string> ExtractWeaponNames(\n        IReadOnlyList<string> headers,\n        IEnumerable<string[]> rows)\n    {\n        var itemClassIdIndex = FindRequiredColumn(headers, \"item_class_id\");\n        var itemNameIndex = FindRequiredColumn(headers, \"item_name\");\n        var requiredColumnCount = Math.Max(itemClassIdIndex, itemNameIndex) + 1;\n        var names = new HashSet<string>(StringComparer.Ordinal);\n\n        foreach (var columns in rows)\n        {\n            if (columns.Length < requiredColumnCount)\n            {\n                throw new InvalidDataException(\"物品原型表存在列数不足的记录。\");\n            }\n\n            if (!columns[itemClassIdIndex].Trim().StartsWith(\"weapon:\", StringComparison.OrdinalIgnoreCase))\n            {\n                continue;\n            }\n\n            var name = columns[itemNameIndex].Trim();\n            if (!string.IsNullOrWhiteSpace(name))\n            {\n                names.Add(name);\n            }\n        }\n\n        if (names.Count == 0)\n        {\n            throw new InvalidDataException(\"物品原型表中没有 item_class_id 以 weapon: 开头的武器记录。\");\n        }","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/CharacterDevelopment/WeaponNameMatcher.cs#L80-L116","documentation":"Thrown by ExtractWeaponNames while iterating CSV rows when a row's column count is less than requiredColumnCount (derived from the maximum index of item_class_id and item_name columns + 1). This protects the subsequent indexed access columns[itemClassIdIndex] / columns[itemNameIndex] from IndexOutOfRange. It indicates the item.csv file is internally inconsistent — the header declared the columns but at least one data row is shorter.","triggerScenarios":"item.csv contains a malformed row with fewer fields than the header, e.g., a trailing line, a partially written row, or a quoting error that caused TextFieldParser to split incorrectly.","commonSituations":"The bundled item.csv was hand-edited or partially overwritten. A game version update changed the CSV export format but only some rows were regenerated. An encoding or line-ending issue (mixed CRLF/LF) corrupted field splitting.","solutions":["Restore item.csv from a clean build or the upstream repository.","Open item.csv in a text editor and check for truncated rows, missing commas, or unescaped quotes near the error.","Validate every row has at least as many columns as the header before loading."],"exampleFix":"null","handlingStrategy":"validation","validationCode":"foreach (var row in rows)\n{\n    if (row.Length < requiredColumnCount) continue; // skip malformed rows\n    // process row\n}","typeGuard":"null","tryCatchPattern":"try { ExtractWeaponNames(headers, rows); }\ncatch (InvalidDataException ex) { /* log corrupt CSV row, restore asset */ }","preventionTips":["Never hand-edit item.csv; regenerate from the official data export tool.","Validate CSV integrity (row column counts) as a post-build check."],"tags":["csv-data","data-validation","weapon-matcher"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}