babalae/better-genshin-impact · error · Exception
未识别的主词条数值:{mainAffixValueLine}
Error message
未识别的主词条数值:{mainAffixValueLine} What it means
Thrown when a main-affix value line was found (153 passed) but float.TryParse fails under NumberStyles.Any and the configured cultureInfo. The captured string is not a parseable number, so the main stat magnitude is unknown.
Source
Thrown at BetterGenshinImpact/GameTask/AutoArtifactSalvage/AutoArtifactSalvageTask.cs:605
}
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;
}
ArtifactAffixType artifactAffixType;
var dic = this.artifactAffixStrDic;
if (match.Groups[1].Value.Contains(dic[ArtifactAffixType.ATK]))View on GitHub (pinned to a7cb36712d)
Solutions
- Log mainAffixValueLine to see the exact unparseable string.
- Align cultureInfo with the in-game locale's number format.
- Pre-clean the string (strip non-numeric except the separator) before TryParse.
- If the value is genuinely non-numeric for this artifact, handle it as a recognition failure per RecognitionFailurePolicy.
Defensive patterns
Strategy: validation
Validate before calling
static string CleanNumber(string s, CultureInfo ci) =>
Regex.Replace(s.Replace('。', '.'), ci.NumberFormat.NumberGroupSeparator, ""); Prevention
- Align cultureInfo with the in-game number locale.
- Pre-clean numeric strings before TryParse.
- Convert full-width digits to half-width.
- Skip the card via RecognitionFailurePolicy when parsing is unreliable.
When it happens
Trigger: The value line contains trailing/leading junk that slipped through the regex (e.g. a unit symbol, a stray letter); decimal separator mismatch with cultureInfo (e.g. '1.5' parsed under a comma-culture); OCR inserted a space inside the number; value is 'MAX' or non-numeric.
Common situations: cultureInfo set to a locale whose decimal separator differs from what OCR emitted; OCR noise characters; a leveled-to-cap artifact showing a non-numeric indicator.
Related errors
- 未识别的副词条数值:{match.Groups[2].Value}
- 未识别的等级:{levelLine}
- 未找到主词条对应的行: {mainAffixText}
- 未找到主词条数值对应的行: {mainAffixText}
- 未识别的副词条:{match.Groups[1].Value}
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/d3052f33c226c00a.
Report an issue: GitHub.