{"record":{"id":"f37bd68fe8827409","repo":"babalae/better-genshin-impact","slug":"error-f37bd6","errorCode":null,"errorMessage":"物品原型表存在无法读取的记录。","messagePattern":"物品原型表存在无法读取的记录。","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/CharacterDevelopment/WeaponNameMatcher.cs","lineNumber":187,"sourceCode":"        if (!File.Exists(path))\n        {\n            throw new FileNotFoundException(\"未找到物品 ONNX 配套表格。\", path);\n        }\n\n        using var parser = new TextFieldParser(path, Encoding.UTF8)\n        {\n            TextFieldType = FieldType.Delimited,\n            HasFieldsEnclosedInQuotes = true,\n            TrimWhiteSpace = false\n        };\n        parser.SetDelimiters(\",\");\n        var headers = parser.ReadFields()\n                      ?? throw new InvalidDataException(\"物品原型表缺少表头。\");\n        var rows = new List<string[]>();\n        while (!parser.EndOfData)\n        {\n            rows.Add(parser.ReadFields()\n                     ?? throw new InvalidDataException(\"物品原型表存在无法读取的记录。\"));\n        }\n\n        return ExtractWeaponNames(headers, rows);\n    }\n\n    private static int FindRequiredColumn(IReadOnlyList<string> headers, string columnName)\n    {\n        for (var i = 0; i < headers.Count; i++)\n        {\n            if (string.Equals(headers[i].Trim(), columnName, StringComparison.OrdinalIgnoreCase))\n            {\n                return i;\n            }\n        }\n\n        throw new InvalidDataException($\"物品原型表缺少必需列 {columnName}。\");\n    }\n}","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/CharacterDevelopment/WeaponNameMatcher.cs#L169-L205","documentation":"Thrown as InvalidDataException by LoadWeaponNames inside the row-reading loop when parser.ReadFields() returns null for a data row (after headers were already read successfully). This indicates the CSV has malformed content mid-file that TextFieldParser cannot parse into fields — typically a quoting or delimiter inconsistency on a specific line.","triggerScenarios":"A data row in item.csv has unmatched quotes, an invalid escape sequence, or a delimiter configuration that makes TextFieldParser fail to produce fields for that line.","commonSituations":"Hand-editing item.csv introduced a syntax error in one row. A data export tool produced a row with embedded commas inside unquoted fields. The file has mixed encodings causing byte-level corruption on certain rows.","solutions":["Inspect item.csv line-by-line around the suspected position for quoting or comma issues.","Restore item.csv from a clean repository copy.","If the CSV is generated, fix the export logic to properly quote fields containing commas."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"while (!parser.EndOfData)\n{\n    try { var fields = parser.ReadFields() ?? throw new InvalidDataException(); rows.Add(fields); }\n    catch (Exception ex) { /* log line number, skip or abort depending on tolerance */ }\n}","preventionTips":["Use a CSV validator on item.csv after any modification.","Ensure consistent quoting and encoding (UTF-8) when regenerating the file."],"tags":["csv-data","malformed-data","weapon-matcher"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}