{"record":{"id":"1016d9421fbd5464","repo":"mgth/LittleBigMouse","slug":"enter-a-vidaa-picture-setting-menu-id-between-1-and-999","errorCode":null,"errorMessage":"Enter a VIDAA picture-setting menu ID between 1 and 999.","messagePattern":"Enter a VIDAA picture-setting menu ID between 1 and 999\\.","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"LittleBigMouse.Plugins/LittleBigMouse.Plugin.Vcp.Avalonia/HisenseVidaa/HisenseVidaaProtocol.cs","lineNumber":140,"sourceCode":"    };\n\n    public static string Topic(string service, string clientId, string action)\n        => $\"/remoteapp/tv/{service}/{clientId}/actions/{action}\";\n\n    /// <summary>\n    /// The token exchange is asked for on a <c>data</c> topic rather than through\n    /// <see cref=\"Topic\"/>'s <c>actions</c> namespace.\n    /// </summary>\n    public static string TokenRequestTopic(string clientId)\n        => $\"/remoteapp/tv/platform_service/{clientId}/data/gettoken\";\n\n    /// <summary>An empty refresh token asks for a first pair of tokens.</summary>\n    public static string TokenRequestPayload() => \"{\\\"refreshtoken\\\":\\\"\\\"}\";\n\n    public static string PictureSettingPayload(int menuId, int value)\n    {\n        if (menuId is < 1 or > 999)\n            throw new ArgumentOutOfRangeException(nameof(menuId), \"Enter a VIDAA picture-setting menu ID between 1 and 999.\");\n        if (value is < -1000 or > 1000)\n            throw new ArgumentOutOfRangeException(nameof(value), \"Enter a VIDAA picture-setting value between -1000 and 1000.\");\n        return JsonSerializer.Serialize(new\n        {\n            action = \"set_value\",\n            menu_id = menuId,\n            menu_value = value,\n            menu_value_type = \"int\",\n        });\n    }\n\n    public static string PictureSettingsRequestPayload()\n        => \"{\\\"action\\\":\\\"get_menu_info\\\"}\";\n\n    public static bool TryParsePictureSettings(\n        string topic,\n        string payload,\n        out IReadOnlyList<VidaaPictureSetting> settings)","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/mgth/LittleBigMouse/blob/7a42f01d47d99d223b8ee33ba4019af82adf1c48/LittleBigMouse.Plugins/LittleBigMouse.Plugin.Vcp.Avalonia/HisenseVidaa/HisenseVidaaProtocol.cs#L122-L158","documentation":"PictureSettingPayload serializes a set_value request for a VIDAA picture menu item. The menuId must be 1..999; otherwise ArgumentOutOfRangeException is thrown for menuId. The bound matches the protocol's menu-id space, so out-of-range values indicate a bad constant or unvalidated user input.","triggerScenarios":"Calling PictureSettingPayload with menuId <= 0 or menuId > 999, e.g. an uninitialized 0, or a parsed value from a config that used a different numbering scheme.","commonSituations":"Hard-coded menu id typo; loading menu ids from an outdated table; passing an index-based (0-based) value where a 1-based menu id is required.","solutions":["Pass a menu id between 1 and 999 (1-based) from a validated source","Validate/normalize the id before calling PictureSettingPayload","Check the value source (config or constant) for off-by-one or stale numbering","Clamp/reject input in the UI layer to 1..999"],"exampleFix":"// before\nvar payload = HisenseVidaaProtocol.PictureSettingPayload(0, 50); // throws\n// after\nif (menuId is < 1 or > 999) return;\nvar payload = HisenseVidaaProtocol.PictureSettingPayload(menuId, 50);","handlingStrategy":"validation","validationCode":"if (menuId is < 1 or > 999) return Result.Fail(\"Menu ID must be 1-999.\");","typeGuard":null,"tryCatchPattern":"try { payload = PictureSettingPayload(menuId, value); }\ncatch (ArgumentOutOfRangeException ex) { ui.Show(ex.ParamName + \" invalid\"); }","preventionTips":["Validate menu ids at the config/UI boundary","Use a typed MenuId wrapper instead of raw int","Keep menu id tables 1-based and documented","Reject 0/negative ids early"],"tags":["validation","argument","range","hisense-vidaa"],"backgroundTag":"argument-out-of-range","analyzedSha":"7a42f01d47d99d223b8ee33ba4019af82adf1c48","analyzedAt":"2026-09-16T00:35:00.514Z","contentChangedAt":"2026-09-16T00:35:00.514Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}