{"record":{"id":"47f794c17e9291de","repo":"babalae/better-genshin-impact","slug":"js-foodeffecttype","errorCode":null,"errorMessage":"JS脚本入参错误：错误的foodEffectType","messagePattern":"JS脚本入参错误：错误的foodEffectType","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/Core/Script/Dependence/Dispatcher.cs","lineNumber":262,"sourceCode":"                                        break;\n                                    case FoodEffectType.AdventurersDish:\n                                        foodName = pathingPartyConfig.AutoEatConfig.DefaultAdventurersDishName;\n                                        if (foodName == null)\n                                        {\n                                            _logger.LogInformation(\"缺少{Text}配置，跳过吃Buff\", \"默认的冒险类料理\");\n                                            return null;\n                                        }\n                                        break;\n                                    case FoodEffectType.DEFBoostingDish:\n                                        foodName = pathingPartyConfig.AutoEatConfig.DefaultDefBoostingDishName;\n                                        if (foodName == null)\n                                        {\n                                            _logger.LogInformation(\"缺少{Text}配置，跳过吃Buff\", \"默认的防御类料理\");\n                                            return null;\n                                        }\n                                        break;\n                                    default:\n                                        throw new NotSupportedException(\"JS脚本入参错误：错误的foodEffectType\");\n                                }\n                            }\n                        }\n                    }\n\n                    var autoEatConfig = TaskContext.Instance().Config.AutoEatConfig;\n                    return await new AutoEatTask(new AutoEatParam()\n                    {\n                        CheckInterval = autoEatConfig.CheckInterval,\n                        EatInterval = autoEatConfig.EatInterval,\n                        ShowNotification = autoEatConfig.ShowNotification,\n                        FoodName = foodName\n                    }).Start(cancellationToken);\n                }\n            case \"CountInventoryItem\":\n                {\n                    if (soloTask.Config == null)\n                    {","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Core/Script/Dependence/Dispatcher.cs#L244-L280","documentation":"NotSupportedException thrown at line 262 in the default branch of the foodEffectType switch. The int value does not match any defined FoodEffectType case (ATKBoostingDish, AdventurersDish, DEFBoostingDish). ScriptObjectConverter.GetValue retrieved a value, so the key existed — it just was not a valid enum member.","triggerScenarios":"JS sets `foodEffectType` to an int outside the enum's range (e.g. 0, 4, 99) or to a value whose underlying int does not correspond to a handled case. Note: the switch handles three named cases; any other int (including a valid-but-unhandled future enum value) hits default.","commonSituations":"Author guessed the numeric value. Enum was extended with new members not yet cased here. Off-by-one or zero-based vs one-based confusion.","solutions":["Use a valid FoodEffectType value: ATKBoostingDish, AdventurersDish, or DEFBoostingDish (check the enum for current underlying ints).","Prefer referencing the enum by name if the JS bridge exposes it rather than hardcoding ints.","If you authored the enum, ensure every member has a case in this switch."],"exampleFix":"// before (JS)\nnew SoloTask('AutoEat', { foodEffectType: 9 }) // no such case -> throws\n\n// after (JS) — use a valid FoodEffectType value\nnew SoloTask('AutoEat', { foodEffectType: 1 }) // e.g. ATKBoostingDish","handlingStrategy":"validation","validationCode":"// JS side\nconst VALID_EFFECTS = new Set([/* ATKBoostingDish, AdventurersDish, DEFBoostingDish ints */]);\nif (foodEffectType != null && !VALID_EFFECTS.has(foodEffectType)) {\n  throw new Error(`Invalid foodEffectType: ${foodEffectType}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only defined FoodEffectType values; do not guess ints.","Reference the enum by name if exposed rather than hardcoding numbers.","Keep a whitelist of handled effect types in your script."],"tags":["script","autoeat","enum","validation"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}