{"record":{"id":"92c33dac4ea12900","repo":"RayWangQvQ/BiliBiliToolPro","slug":"invalid-taskcode-taskcode","errorCode":null,"errorMessage":"Invalid taskCode: {taskCode}","messagePattern":"Invalid taskCode: (.+?)","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Ray.BiliBiliTool.DomainService/VipBigPointDomainService.cs","lineNumber":216,"sourceCode":"        var request = new ReceiveOrCompleteTaskRequest(taskCode);\n        var re = await apiApi.VipBigPointCompleteAsync(request, ck.ToString());\n        if (re.Code == 0)\n        {\n            logger.LogInformation(\"已完成\");\n            return true;\n        }\n\n        logger.LogInformation(\"失败：{msg}\", re.ToJsonStr());\n        return false;\n    }\n\n    public async Task<bool> CompleteViewAsync(string taskCode, BiliCookie ck)\n    {\n        var channel = taskCode switch\n        {\n            \"animatetab\" => \"jp_channel\",\n            \"filmtab\" => \"tv_channel\",\n            _ => throw new ArgumentOutOfRangeException(\n                nameof(taskCode),\n                $\"Invalid taskCode: {taskCode}\"\n            ),\n        };\n\n        logger.LogInformation(\"开始浏览\");\n        await Task.Delay(10 * 1000);\n\n        var request = new ViewRequest(channel);\n        var re = await apiApi.VipBigPointViewComplete(request, ck.ToString());\n        if (re.Code == 0)\n        {\n            logger.LogInformation(\"浏览完成\");\n            return true;\n        }\n\n        logger.LogInformation(\"浏览失败：{msg}\", re.ToJsonStr());\n        return false;","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/RayWangQvQ/BiliBiliToolPro/blob/c599b2c0da964e16ea8c454397aa07bb16212628/src/Ray.BiliBiliTool.DomainService/VipBigPointDomainService.cs#L198-L234","documentation":"CompleteViewAsync maps a VIP viewing task code (taskCode) to a channel via a switch expression; any taskCode other than 'animatetab' or 'filmtab' throws ArgumentOutOfRangeException with 'Invalid taskCode: {taskCode}'. This is a local guard against calling the view-completion flow with an unsupported task identifier.","triggerScenarios":"Calling CompleteViewAsync directly with a taskCode string obtained from a different task list (e.g. 'viewcomplete' or a numeric code) that isn't one of the two supported viewing tabs, or after Bilibili introduces a new tab code the mapping doesn't handle.","commonSituations":"Custom task automation passing codes from GetCombineAsync's task list; Bilibili renaming/adding tab codes upstream; typo in the taskCode string when wiring up tasks manually.","solutions":["Only pass 'animatetab' or 'filmtab' to CompleteViewAsync; route other task codes to CompleteV2Async instead.","Add the new tab code to the switch mapping if Bilibili introduced one (e.g. \"newtab\" => \"new_channel\").","Log the full task list from GetCombineAsync and pick codes the service explicitly supports.","Validate taskCode before calling to avoid an unhandled exception in the daily run."],"exampleFix":"// before\nawait service.CompleteViewAsync(\"viewcomplete\", ck);\n// after\nif (taskCode is \"animatetab\" or \"filmtab\")\n    await service.CompleteViewAsync(taskCode, ck);\nelse\n    await service.CompleteV2Async(taskCode, ck);","handlingStrategy":"validation","validationCode":"private static readonly HashSet<string> SupportedViewTaskCodes = new() { \"animatetab\", \"filmtab\" };\nif (!SupportedViewTaskCodes.Contains(taskCode))\n{\n    logger.LogWarning(\"跳过不支持的任务Code: {TaskCode}\", taskCode);\n    return false;\n}","typeGuard":null,"tryCatchPattern":"try { await svc.CompleteViewAsync(taskCode, ck); }\ncatch (ArgumentOutOfRangeException)\n{\n    logger.LogWarning(\"任务Code {TaskCode} 不支持浏览完成，改用CompleteV2Async\", taskCode);\n    await svc.CompleteV2Async(taskCode, ck);\n}","preventionTips":["Only pass 'animatetab' or 'filmtab' to CompleteViewAsync","Route other task codes to CompleteV2Async","Check upstream task lists for new tab codes after Bilibili changes","Validate codes from GetCombineAsync before dispatching"],"tags":["argument-validation","task-code","vip","switch-mapping"],"backgroundTag":"invalid-enum-value","analyzedSha":"c599b2c0da964e16ea8c454397aa07bb16212628","analyzedAt":"2026-09-12T09:48:04.090Z","contentChangedAt":"2026-09-12T09:48:04.090Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}