mgth/LittleBigMouse · error · ArgumentException

Enter a platform action name containing only letters…

Error message

Enter a platform action name containing only letters, digits, '_' or '-'.

What it means

PlatformActionName validates a Hisense VIDAA platform action name before it is used in an MQTT topic/payload. The name must be non-empty, at most 64 characters, and contain only ASCII letters, digits, '_' or '-'. Any other character (spaces, dots, slashes, non-ASCII) makes the library throw ArgumentException to prevent malformed platform action identifiers from being sent to the device.

Solutions

  1. Remove or replace disallowed characters (spaces, dots, slashes) with '_' or '-' before calling PlatformActionName.
  2. Trim and cap the name at 64 characters.
  3. Restrict action names to ASCII letters, digits, '_' and '-' at the point where users enter or select them.
  4. Wrap the call in try/catch on ArgumentException to surface a friendly validation message in the UI.

Example fix

// before
var name = PlatformActionName(userInput); // throws for 'Volume Up'
// after
var cleaned = new string(userInput.Trim().Select(c => char.IsAsciiLetterOrDigit(c) ? c : (c == ' ' ? '_' : '-')).ToArray()).Take(64).ToArray();
var name = PlatformActionName(new string(cleaned));
Defensive patterns

Strategy: validation

Validate before calling

public static bool IsValidPlatformActionName(string? action) =>
    action is not null &&
    action.Trim() is { Length: > 0 } n && n.Length <= 64 &&
    n.All(c => char.IsAsciiLetterOrDigit(c) || c is '_' or '-');

Type guard

public static bool IsSafeActionName(string? s) => !string.IsNullOrWhiteSpace(s) && s.Trim().Length <= 64 && s.All(c => char.IsAsciiLetterOrDigit(c) || c == '_' || c == '-');

Try / catch

try { var name = HisenseVidaaProtocol.PlatformActionName(input); }
catch (ArgumentException ex) { ShowValidationError(ex.Message); }

Prevention

When it happens

Trigger: Calling HisenseVidaaProtocol.PlatformActionName with: an empty or whitespace-only string; a string longer than 64 chars after Trim(); or any string containing characters outside [A-Za-z0-9_-] (e.g. 'Volume Up', 'vol.up', 'ação').

Common situations: Hardcoding action names with spaces or dots copied from documentation; building action names dynamically from user input or UI labels that were never sanitized; localizing names so accented characters sneak in; concatenating prefixes that exceed 64 characters.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

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

        catch (JsonException)
        {
            return false;
        }
    }

    public static string VolumePayload(int volume)
    {
        if (volume is < 0 or > 100)
            throw new ArgumentOutOfRangeException(nameof(volume), "Enter a volume between 0 and 100.");
        return volume.ToString(CultureInfo.InvariantCulture);
    }

    public static string PlatformActionName(string action)
    {
        var normalized = action.Trim();
        if (normalized.Length is 0 or > 64
            || normalized.Any(c => !char.IsAsciiLetterOrDigit(c) && c is not '_' and not '-'))
            throw new ArgumentException(
                "Enter a platform action name containing only letters, digits, '_' or '-'.",
                nameof(action));
        return normalized;
    }

    public static string ExperimentalLevelPayload(int value)
    {
        if (value is < 0 or > 10)
            throw new ArgumentOutOfRangeException(nameof(value), "Enter a test level between 0 and 10.");
        return value.ToString(CultureInfo.InvariantCulture);
    }

    public static bool TryParseVolume(string topic, string payload, out int volume)
    {
        volume = 0;
        if (!topic.EndsWith("/platform_service/actions/volumechange", StringComparison.OrdinalIgnoreCase))
            return false;
        try

View on GitHub (pinned to 7a42f01d47)