{"record":{"id":"0ca890e7a490c171","repo":"babalae/better-genshin-impact","slug":"error-0ca890","errorCode":null,"errorMessage":"背包物品计数参数不能为空","messagePattern":"背包物品计数参数不能为空","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/Core/Script/Dependence/Dispatcher.cs","lineNumber":449,"sourceCode":"        {\n            throw new ArgumentNullException(nameof(param), \"自动幽境危战任务参数不能为空\");\n        }\n\n        CancellationToken cancellationToken = customCt ?? CancellationContext.Instance.Cts.Token;\n        await new AutoStygianOnslaughtTask(param).Start(cancellationToken);\n    }\n    \n    /// <summary>\n    /// 运行背包物品计数任务。\n    /// </summary>\n    /// <param name=\"param\">背包物品计数参数。</param>\n    /// <param name=\"customCt\">自定义取消令牌。</param>\n    /// <returns>单物品返回数量；多物品返回名称到数量的脚本对象。</returns>\n    public async Task<object?> RunCountInventoryItemTask(CountInventoryItemParam param, CancellationToken? customCt = null)\n    {\n        if (param == null)\n        {\n            throw new ArgumentNullException(nameof(param), \"背包物品计数参数不能为空\");\n        }\n\n        CancellationToken cancellationToken = customCt ?? CancellationContext.Instance.Cts.Token;\n        object result = await new CountInventoryItem(param).Start(cancellationToken);\n\n        if (param.ItemName != null)\n        {\n            return result;\n        }\n        else\n        {\n            dynamic expando = new ExpandoObject();\n            var expandoDict = (IDictionary<string, object>)expando;\n            foreach (var kvp in (Dictionary<string, int>)result)\n            {\n                expandoDict[kvp.Key] = kvp.Value;\n            }\n","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Core/Script/Dependence/Dispatcher.cs#L431-L467","documentation":"ArgumentNullException thrown by RunCountInventoryItemTask at line 449 when the CountInventoryItemParam argument is null. Unlike the RunTask('CountInventoryItem') path (errors 69-70), this typed overload takes a ready CountInventoryItemParam directly; a null param has no grid/item data.","triggerScenarios":"JS calls `dispatcher.RunCountInventoryItemTask(null)` or passes an undefined variable.","commonSituations":"Author forgot to construct CountInventoryItemParam. Param built conditionally and the branch did not run.","solutions":["Construct CountInventoryItemParam with GridScreenName and ItemName/ItemNames before calling.","Null-check in JS before invoking."],"exampleFix":"// before (JS)\ndispatcher.RunCountInventoryItemTask(param); // null -> throws\n\n// after (JS)\nconst cParam = new CountInventoryItemParam({ GridScreenName: '5x10', ItemName: 'Mora' });\ndispatcher.RunCountInventoryItemTask(cParam);","handlingStrategy":"validation","validationCode":"// JS side\nif (!param) throw new Error('CountInventoryItemParam is required');\ndispatcher.RunCountInventoryItemTask(param);","typeGuard":"// JS\nfunction isCountInventoryParam(v) { return v != null && typeof v === 'object' && typeof v.GridScreenName !== 'undefined'; }","tryCatchPattern":null,"preventionTips":["Construct CountInventoryItemParam with GridScreenName and ItemName/ItemNames before calling.","Null-check params in JS wrappers.","Prefer the typed RunCountInventoryItemTask over RunTask('CountInventoryItem') when you already have a param."],"tags":["script","argument-null","count-inventory","dispatcher"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}