mgth/LittleBigMouse · error · ArgumentOutOfRangeException

Enter a VIDAA picture-setting menu ID between 1 and 999.

Error message

Enter a VIDAA picture-setting menu ID between 1 and 999.

What it means

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.

Solutions

  1. Pass a menu id between 1 and 999 (1-based) from a validated source
  2. Validate/normalize the id before calling PictureSettingPayload
  3. Check the value source (config or constant) for off-by-one or stale numbering
  4. Clamp/reject input in the UI layer to 1..999

Example fix

// before
var payload = HisenseVidaaProtocol.PictureSettingPayload(0, 50); // throws
// after
if (menuId is < 1 or > 999) return;
var payload = HisenseVidaaProtocol.PictureSettingPayload(menuId, 50);
Defensive patterns

Strategy: validation

Validate before calling

if (menuId is < 1 or > 999) return Result.Fail("Menu ID must be 1-999.");

Try / catch

try { payload = PictureSettingPayload(menuId, value); }
catch (ArgumentOutOfRangeException ex) { ui.Show(ex.ParamName + " invalid"); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of mgth/LittleBigMouse@7a42f01d47 (2026-09-16). Data as JSON: /api/errors/1016d9421fbd5464. Report an issue: GitHub.

Appendix: source

Thrown at LittleBigMouse.Plugins/LittleBigMouse.Plugin.Vcp.Avalonia/HisenseVidaa/HisenseVidaaProtocol.cs:140

    };

    public static string Topic(string service, string clientId, string action)
        => $"/remoteapp/tv/{service}/{clientId}/actions/{action}";

    /// <summary>
    /// The token exchange is asked for on a <c>data</c> topic rather than through
    /// <see cref="Topic"/>'s <c>actions</c> namespace.
    /// </summary>
    public static string TokenRequestTopic(string clientId)
        => $"/remoteapp/tv/platform_service/{clientId}/data/gettoken";

    /// <summary>An empty refresh token asks for a first pair of tokens.</summary>
    public static string TokenRequestPayload() => "{\"refreshtoken\":\"\"}";

    public static string PictureSettingPayload(int menuId, int value)
    {
        if (menuId is < 1 or > 999)
            throw new ArgumentOutOfRangeException(nameof(menuId), "Enter a VIDAA picture-setting menu ID between 1 and 999.");
        if (value is < -1000 or > 1000)
            throw new ArgumentOutOfRangeException(nameof(value), "Enter a VIDAA picture-setting value between -1000 and 1000.");
        return JsonSerializer.Serialize(new
        {
            action = "set_value",
            menu_id = menuId,
            menu_value = value,
            menu_value_type = "int",
        });
    }

    public static string PictureSettingsRequestPayload()
        => "{\"action\":\"get_menu_info\"}";

    public static bool TryParsePictureSettings(
        string topic,
        string payload,
        out IReadOnlyList<VidaaPictureSetting> settings)

View on GitHub (pinned to 7a42f01d47)