{"record":{"id":"e698626fb50d54c1","repo":"mgth/LittleBigMouse","slug":"invalid-vidaa-remote-key","errorCode":null,"errorMessage":"Invalid VIDAA remote key.","messagePattern":"Invalid VIDAA remote key\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"LittleBigMouse.Plugins/LittleBigMouse.Plugin.Vcp.Avalonia/HisenseVidaa/HisenseVidaaProtocol.cs","lineNumber":121,"sourceCode":"            model,\n            NormalizeMac(mac),\n            protocol,\n            First(raw, \"brand\") is { Length: > 0 } brand ? brand : \"his\");\n    }\n\n    public static string TranslateKey(string key) => key.Trim().ToUpperInvariant() switch\n    {\n        \"KEY_ENTER\" => \"KEY_OK\",\n        \"KEY_RETURN\" => \"KEY_RETURNS\",\n        \"KEY_VOLUP\" => \"KEY_VOLUMEUP\",\n        \"KEY_VOLDOWN\" => \"KEY_VOLUMEDOWN\",\n        \"KEY_CHUP\" => \"KEY_CHANNELUP\",\n        \"KEY_CHDOWN\" => \"KEY_CHANNELDOWN\",\n        \"KEY_PLAYPAUSE\" => \"KEY_PLAY\",\n        \"KEY_FF\" => \"KEY_FORWARDS\",\n        \"KEY_REWIND\" => \"KEY_BACKWARDS\",\n        var value when value.StartsWith(\"KEY_\", StringComparison.Ordinal) => value,\n        _ => throw new ArgumentException(\"Invalid VIDAA remote key.\", nameof(key)),\n    };\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)","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/mgth/LittleBigMouse/blob/7a42f01d47d99d223b8ee33ba4019af82adf1c48/LittleBigMouse.Plugins/LittleBigMouse.Plugin.Vcp.Avalonia/HisenseVidaa/HisenseVidaaProtocol.cs#L103-L139","documentation":"TranslateKey maps library-facing remote key names to VIDAA protocol key codes. Keys not matching a known alias and not already starting with 'KEY_' are rejected with ArgumentException naming the key parameter. It is a whitelist check to avoid sending garbage key codes to the TV.","triggerScenarios":"Calling TranslateKey with a name like \"volume_up\", \"OK\", \"power\", or an empty string that isn't in the alias table and lacks the KEY_ prefix.","commonSituations":"Binding UI buttons to invented key names; translating from another remote-control library's key names; casing mistakes (VIDAA keys are uppercase with underscores).","solutions":["Use a recognized key constant (e.g. KEY_POWER, KEY_VOLUP, KEY_OK) or an alias from the mapping table","Uppercase the name and prefix it with KEY_ if your key is not in the alias table","Extend/wrap TranslateKey with your own mapping before calling it","Check the VIDAA remote key list in the protocol source for valid names"],"exampleFix":"// before\nvar code = HisenseVidaaProtocol.TranslateKey(\"volume_up\"); // throws\n// after\nvar code = HisenseVidaaProtocol.TranslateKey(\"KEY_VOLUP\");","handlingStrategy":"validation","validationCode":"bool IsValidVidaaKey(string k) =>\n    k.StartsWith(\"KEY_\", StringComparison.Ordinal) || KnownAliases.Contains(k);","typeGuard":"bool IsRemoteKey(object k) => k is string s && s.Length > 0 && (s.StartsWith(\"KEY_\") || AliasTable.ContainsKey(s));","tryCatchPattern":"try { code = TranslateKey(key); }\ncatch (ArgumentException ex) { log.Warn($\"Unknown key {key}\"); }","preventionTips":["Centralize key constants instead of inline strings","Keep UI button bindings in one validated map","Use exact uppercase KEY_ names","Extend the alias table rather than inventing keys at call sites"],"tags":["validation","argument","remote-control","hisense-vidaa"],"backgroundTag":"invalid-enum-value","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"}