{"record":{"id":"0d8d3dc333ef3ee1","repo":"mgth/LittleBigMouse","slug":"enter-a-volume-between-0-and-100","errorCode":null,"errorMessage":"Enter a volume between 0 and 100.","messagePattern":"Enter a volume between 0 and 100\\.","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"LittleBigMouse.Plugins/LittleBigMouse.Plugin.Vcp.Avalonia/HisenseVidaa/HisenseVidaaProtocol.cs","lineNumber":196,"sourceCode":"                    if (ParsePictureSetting(item) is { } setting) result.Add(setting);\n            }\n            else if (ParsePictureSetting(root) is { } setting)\n            {\n                result.Add(setting);\n            }\n            settings = result;\n            return result.Count > 0;\n        }\n        catch (JsonException)\n        {\n            return false;\n        }\n    }\n\n    public static string VolumePayload(int volume)\n    {\n        if (volume is < 0 or > 100)\n            throw new ArgumentOutOfRangeException(nameof(volume), \"Enter a volume between 0 and 100.\");\n        return volume.ToString(CultureInfo.InvariantCulture);\n    }\n\n    public static string PlatformActionName(string action)\n    {\n        var normalized = action.Trim();\n        if (normalized.Length is 0 or > 64\n            || normalized.Any(c => !char.IsAsciiLetterOrDigit(c) && c is not '_' and not '-'))\n            throw new ArgumentException(\n                \"Enter a platform action name containing only letters, digits, '_' or '-'.\",\n                nameof(action));\n        return normalized;\n    }\n\n    public static string ExperimentalLevelPayload(int value)\n    {\n        if (value is < 0 or > 10)\n            throw new ArgumentOutOfRangeException(nameof(value), \"Enter a test level between 0 and 10.\");","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/mgth/LittleBigMouse/blob/7a42f01d47d99d223b8ee33ba4019af82adf1c48/LittleBigMouse.Plugins/LittleBigMouse.Plugin.Vcp.Avalonia/HisenseVidaa/HisenseVidaaProtocol.cs#L178-L214","documentation":"VolumePayload converts an integer volume level to the VIDAA protocol string form. VIDAA volume is 0..100, so VolumePayload throws ArgumentOutOfRangeException for any volume outside that range, guarding against sending invalid volume values to the TV.","triggerScenarios":"Calling VolumePayload with volume < 0 or > 100, e.g. passing a dB value, a 0..255 raw level, or an unclamped slider value.","commonSituations":"Mapping from another API's volume scale (0..255, 0.0..1.0 floats, dB values) without conversion; arithmetic like volume + step pushing past 100.","solutions":["Clamp volume to [0, 100] before calling VolumePayload","Convert other volume scales (float 0..1, 0..255) to integer percentage first","Use Math.Clamp when adjusting volume in steps so it never leaves range","Validate at the UI layer (slider max = 100)"],"exampleFix":"// before\nvar payload = HisenseVidaaProtocol.VolumePayload(rawVolume); // rawVolume may be 0..255\n// after\nvar v = (int)Math.Round(rawVolume / 255.0 * 100);\nvar payload = HisenseVidaaProtocol.VolumePayload(Math.Clamp(v, 0, 100));","handlingStrategy":"validation","validationCode":"if (volume is < 0 or > 100) volume = Math.Clamp(volume, 0, 100);","typeGuard":null,"tryCatchPattern":"try { payload = VolumePayload(volume); }\ncatch (ArgumentOutOfRangeException ex) { volume = Math.Clamp(volume, 0, 100); payload = VolumePayload(volume); }","preventionTips":["Clamp on every volume step adjustment","Convert other scales (0..255, 0..1) to percent first","Constrain the UI slider to 0..100","Represent volume as a bounded Volume type"],"tags":["validation","argument","volume","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"}