{"record":{"id":"e52deb1f1a2fe171","repo":"babalae/better-genshin-impact","slug":"json-info","errorCode":null,"errorMessage":"JSON 战斗策略缺少 Info 节点","messagePattern":"JSON 战斗策略缺少 Info 节点","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/AutoFight/Script/JsonCombatStrategyParser.cs","lineNumber":63,"sourceCode":"        {\n            strategy = JsonConvert.DeserializeObject<JsonCombatStrategy>(json);\n        }\n        catch (JsonException ex)\n        {\n            Logger.LogError(\"JSON 战斗策略解析失败：{Msg}\", ex.Message);\n            throw new InvalidOperationException($\"JSON 战斗策略格式错误：{ex.Message}\", ex);\n        }\n\n        if (strategy == null)\n        {\n            Logger.LogError(\"JSON 战斗策略反序列化结果为空\");\n            throw new InvalidOperationException(\"JSON 战斗策略反序列化失败\");\n        }\n\n        if (strategy.Info == null)\n        {\n            Logger.LogError(\"JSON 战斗策略缺少 Info 节点\");\n            throw new InvalidOperationException(\"JSON 战斗策略缺少 Info 节点\");\n        }\n\n        if (strategy.Actions == null || strategy.Actions.Count == 0)\n        {\n            Logger.LogError(\"JSON 战斗策略缺少 Actions 节点或动作为空\");\n            throw new InvalidOperationException(\"JSON 战斗策略中未定义任何动作\");\n        }\n\n        // 校验动作合法性（名称需能作为条件标识符解析；index 允许重复）\n        ValidateActions(strategy.Actions);\n\n        Logger.LogInformation(\"JSON 战斗策略加载完成：{Name}，共 {Count} 个动作\",\n            strategy.Info.Name, strategy.Actions.Count);\n\n        return strategy;\n    }\n\n    /// <summary>","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/AutoFight/Script/JsonCombatStrategyParser.cs#L45-L81","documentation":"Thrown by JsonCombatStrategyParser.Parse when the deserialized strategy object is non-null but its Info property is null. The Info node is required — it contains strategy metadata (name, etc.). This means the JSON object exists but lacks the 'Info' key or it was explicitly set to null.","triggerScenarios":"The JSON file has an 'Actions' array but no 'Info' object, or 'Info' is present but set to null. For example: `{ \"Actions\": [...] }` without an Info key, or `{ \"Info\": null, \"Actions\": [...] }`.","commonSituations":"User creates a strategy file from a partial template that omitted the Info section, or deletes the Info block while editing. The Info node carries the human-readable strategy name used in logs.","solutions":["Add an 'Info' object with at least a 'Name' property to the JSON strategy.","Use the documented JSON strategy schema/template as a starting point.","Example: \"Info\": { \"Name\": \"MyCombatStrategy\" }."],"exampleFix":"// before (missing Info)\n{\n  \"Actions\": [ { \"Name\": \"a1\", \"Index\": 1 } ]\n}\n\n// after\n{\n  \"Info\": { \"Name\": \"MyStrategy\" },\n  \"Actions\": [ { \"Name\": \"a1\", \"Index\": 1 } ]\n}","handlingStrategy":"validation","validationCode":"// Pre-check for the Info node using a lightweight parse\nusing System.Text.Json;\n\nvar doc = System.Text.Json.JsonDocument.Parse(json);\nif (!doc.RootElement.TryGetProperty(\"Info\", out _) || doc.RootElement.GetProperty(\"Info\").ValueKind == JsonValueKind.Null)\n{\n    throw new ArgumentException(\"策略缺少 Info 节点\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var strategy = JsonCombatStrategyParser.Parse(json);\n}\ncatch (InvalidOperationException e) when (e.Message.Contains(\"缺少 Info 节点\"))\n{\n    Logger.LogError(\"策略缺少 Info 节点，请添加 Info 对象\");\n}","preventionTips":["Always include an Info object in strategy files, even minimally: \"Info\": { \"Name\": \"...\" }.","Use a strategy file template as a starting point to avoid missing required sections.","Validate the file structure with a JSON schema or template comparison."],"tags":["json-strategy","validation","missing-field","info"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}