babalae/better-genshin-impact · critical · Exception
节点数据解析失败
Error message
节点数据解析失败
What it means
Thrown by AutoLeyLineOutcropTask.LoadNodeData when JsonSerializer.Deserialize<RawNodeData> on the bundled asset GameTask\AutoLeyLineOutcrop\Assets\LeyLineOutcropData.json returns null. The null-coalescing throw converts a silent null into a hard failure, so the node graph for ley-line routing is unavailable.
Source
Thrown at BetterGenshinImpact/GameTask/AutoLeyLineOutcrop/AutoLeyLineOutcropTask.cs:763
return partyConfig;
}
private async Task<NodeData> LoadNodeData()
{
if (_nodeData != null)
{
return _nodeData;
}
var workDir = Global.Absolute(@"GameTask\AutoLeyLineOutcrop");
var nodePath = Path.Combine(workDir, "Assets", "LeyLineOutcropData.json");
if (!File.Exists(nodePath))
{
throw new FileNotFoundException("LeyLineOutcropData.json 未找到", nodePath);
}
var raw = JsonSerializer.Deserialize<RawNodeData>(File.ReadAllText(nodePath))
?? throw new Exception("节点数据解析失败");
_nodeData = AdaptNodeData(raw);
return _nodeData;
}
private static NodeData AdaptNodeData(RawNodeData raw)
{
var nodes = new List<Node>();
foreach (var teleport in raw.Teleports)
{
nodes.Add(new Node
{
Id = teleport.Id,
Region = teleport.Region,
Position = teleport.Position,
Type = "teleport",
Next = new List<NodeRoute>(),
Prev = new List<int>()
});View on GitHub (pinned to a7cb36712d)
Solutions
- Open GameTask\AutoLeyLineOutcrop\Assets\LeyLineOutcropData.json and confirm it is valid JSON with a non-null object root matching RawNodeData (Teleports, Blossoms, Edges, Indexes).
- Restore the asset from source control if it was corrupted or emptied.
- Ensure the build/publish pipeline copies the asset with full content into the output directory (check the .csproj CopyToOutputDirectory / None include for this file).
Example fix
// before
var raw = JsonSerializer.Deserialize<RawNodeData>(File.ReadAllText(nodePath))
?? throw new Exception("节点数据解析失败");
// after — surface the actual problem instead of an opaque null
var nodeText = File.ReadAllText(nodePath);
if (string.IsNullOrWhiteSpace(nodeText) || nodeText.Trim() == "null")
{
throw new InvalidOperationException($"LeyLineOutcropData.json 内容无效或为空: {nodePath}");
}
var raw = JsonSerializer.Deserialize<RawNodeData>(nodeText)
?? throw new InvalidOperationException($"LeyLineOutcropData.json 反序列化结果为 null: {nodePath}"); Defensive patterns
Strategy: validation
Validate before calling
var nodePath = Path.Combine(Global.Absolute("GameTask\\AutoLeyLineOutcrop"), "Assets", "LeyLineOutcropData.json");
if (!File.Exists(nodePath)) throw new FileNotFoundException("缺少地脉节点数据资产", nodePath);
var text = File.ReadAllText(nodePath);
if (string.IsNullOrWhiteSpace(text) || text.Trim() == "null")
{
throw new InvalidOperationException($"LeyLineOutcropData.json 内容无效: {nodePath}");
} Prevention
- Add a CI/build step that validates every bundled JSON asset deserializes to a non-null object.
- Mark LeyLineOutcropData.json as CopyToOutputDirectory and assert it is non-empty in the publish output.
- Treat a null deserialize result as a data-integrity bug, not a runtime path.
When it happens
Trigger: LoadNodeData() is called the first time (_nodeData is null). The JSON file exists (File.Exists passed) but its content deserializes to null — e.g. the file body is literally "null", empty, or whitespace so System.Text.Json yields null for the reference type.
Common situations: The shipped asset got truncated/emptied by a publish step, a merge conflict, or an editor save that wrote "null". A custom build dropped the file content while leaving the file present.
Related errors
- 无法解析 RecognitionObject 配置文件: {filePath}
- config.json 解析失败
- Failed to deserialize macro
- 解析配置组JSON配置失败
- Failed to deserialize JSON.
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/57e6e0d736c115ff.
Report an issue: GitHub.