babalae/better-genshin-impact · error · Exception
未找到主词条数值对应的行: {mainAffixText}
Error message
未找到主词条数值对应的行:
{mainAffixText} What it means
Thrown when the main-affix value line cannot be found: the LINQ Select over mainAffixLines matching the numeric pattern '^([\d., ]*)(%?)$' yields no single match. The artifact's main stat type was identified (152 passed) but its numeric value line is missing.
Source
Thrown at BetterGenshinImpact/GameTask/AutoArtifactSalvage/AutoArtifactSalvageTask.cs:602
if (mainAffixType == ArtifactAffixType.ATK && !String.IsNullOrEmpty(match.Groups[2].Value))
{
mainAffixType = ArtifactAffixType.ATKPercent;
}
if (mainAffixType == ArtifactAffixType.DEF && !String.IsNullOrEmpty(match.Groups[2].Value))
{
mainAffixType = ArtifactAffixType.DEFPercent;
}
if (mainAffixType == ArtifactAffixType.HP && !String.IsNullOrEmpty(match.Groups[2].Value))
{
mainAffixType = ArtifactAffixType.HPPercent;
}
return match.Groups[1].Value;
}
else
{
return null;
}
}).Where(l => l != null).Cast<string>().SingleOrDefault() ?? throw new Exception($"未找到主词条数值对应的行:\n{mainAffixText}");
if (!float.TryParse(mainAffixValueLine, NumberStyles.Any, this.cultureInfo, out float value))
{
throw new Exception($"未识别的主词条数值:{mainAffixValueLine}");
}
ArtifactAffix mainAffix = new ArtifactAffix(mainAffixType, value);
#endregion
#region 副词条
var minorAffixes = new List<ArtifactAffix>();
string pattern = @"^([^+::]+)\+([\d., 。]*)(%?).*$";
pattern = pattern.Replace("%", percentStr);
foreach (var r in levelAndMinorAffixResult)
{
Match match = Regex.Match(r.Text, pattern);
if (!match.Success)
{
continue;
}View on GitHub (pinned to a7cb36712d)
Solutions
- Check allText / mainAffixText to see the captured value line format.
- Confirm cultureInfo matches the in-game number formatting.
- Widen mainAffixRoi if the value moved outside the crop.
- Adjust the numeric regex to accept the locale's separators.
Defensive patterns
Strategy: try-catch
Try / catch
try { /* parse main affix value */ }
catch (Exception e) when (e.Message.Contains("主词条数值")) { if (policy == RecognitionFailurePolicy.Skip) continue; throw; } Prevention
- Confirm cultureInfo's decimal/thousands separators match OCR output.
- Inspect mainAffixText to validate the captured lines.
- Widen mainAffixRoi if the value line is cropped out.
- Allow RecognitionFailurePolicy to skip unreliable cards.
When it happens
Trigger: OCR split the value across multiple lines or merged it with the type label; value contains characters the regex rejects (e.g. local decimal separator not in [\d., ]); the threshold step removed the value text; multiple lines matched causing SingleOrDefault to throw InvalidOperationException instead (distinct failure).
Common situations: Locale using a thousands separator outside the allowed set (e.g. space grouping already allowed, but apostrophe in some locales); UI scale change cropped the value out of mainAffixRoi; OCR mis-detection.
Related errors
- 未识别的副词条:{match.Groups[1].Value}
- 未找到等级对应的行:\n{levelAndMinorAffixLines}
- 未找到主词条对应的行: {mainAffixText}
- 未识别的主词条数值:{mainAffixValueLine}
- 未识别的副词条数值:{match.Groups[2].Value}
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/36684fee5b624463.
Report an issue: GitHub.