babalae/better-genshin-impact · error · InvalidDataException

物品原型表缺少必需列 {columnName}。

Error message

物品原型表缺少必需列 {columnName}。

What it means

Thrown as InvalidDataException by FindRequiredColumn when neither 'item_class_id' nor 'item_name' (case-insensitive, trimmed) is found among the CSV headers. The extractor needs both columns to locate weapon records and their names. Without them it cannot determine which column holds the class id or the name.

Source

Thrown at BetterGenshinImpact/GameTask/CharacterDevelopment/WeaponNameMatcher.cs:203

        {
            rows.Add(parser.ReadFields()
                     ?? throw new InvalidDataException("物品原型表存在无法读取的记录。"));
        }

        return ExtractWeaponNames(headers, rows);
    }

    private static int FindRequiredColumn(IReadOnlyList<string> headers, string columnName)
    {
        for (var i = 0; i < headers.Count; i++)
        {
            if (string.Equals(headers[i].Trim(), columnName, StringComparison.OrdinalIgnoreCase))
            {
                return i;
            }
        }

        throw new InvalidDataException($"物品原型表缺少必需列 {columnName}。");
    }
}

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Open item.csv and verify the header row contains 'item_class_id' and 'item_name' exactly (case-insensitive).
  2. If the column names changed, update WeaponNameMatcher.FindRequiredColumn or rename the CSV headers.
  3. Restore the correct item.csv from the project's bundled assets.

Example fix

null
Defensive patterns

Strategy: validation

Validate before calling

var hasClassId = headers.Any(h => string.Equals(h.Trim(), "item_class_id", StringComparison.OrdinalIgnoreCase));
var hasName = headers.Any(h => string.Equals(h.Trim(), "item_name", StringComparison.OrdinalIgnoreCase));
if (!hasClassId || !hasName) { /* abort: schema mismatch */ }

Type guard

null

Try / catch

try { FindRequiredColumn(headers, "item_class_id"); }
catch (InvalidDataException ex) { /* log missing column, restore correct CSV */ }

Prevention

When it happens

Trigger: The item.csv header row does not contain columns named 'item_class_id' and/or 'item_name', either because the file is a different CSV variant, the column was renamed, or the header uses different casing/whitespace that does not match the OrdinalIgnoreCase comparison.

Common situations: A wrong CSV file was placed at the item.csv path (e.g., a material-only export). A game data update renamed columns. The CSV uses a different locale naming convention for headers.

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/e6c7db6f0452fb7a. Report an issue: GitHub.