Devolutions/UniGetUI · error · InvalidOperationException

The value supplied to {argumentName} must be either true or

Error message

The value supplied to {argumentName} must be either true or false.

What it means

Thrown by GetOptionalBoolArgument when an optional boolean flag is present but its value is not accepted by bool.TryParse (True/False case-insensitive only; not 1/0/yes/no). This helper backs flags like --include-installed, --elevated, --interactive, --skip-hash on bundle install.

Source

Thrown at src/UniGetUI.Interface.IpcApi/IpcCliCommandRunner.cs:815

    }

    private static bool? GetOptionalBoolArgument(
        IReadOnlyList<string> arguments,
        string argumentName
    )
    {
        string? value = GetOptionalArgument(arguments, argumentName);
        if (value is null)
        {
            return null;
        }

        if (bool.TryParse(value, out bool result))
        {
            return result;
        }

        throw new InvalidOperationException(
            $"The value supplied to {argumentName} must be either true or false."
        );
    }

    private static bool GetRequiredBoolArgument(IReadOnlyList<string> arguments, string argumentName)
    {
        bool? value = GetOptionalBoolArgument(arguments, argumentName);
        if (!value.HasValue)
        {
            throw new InvalidOperationException(
                $"This command requires {argumentName} with a value of true or false."
            );
        }

        return value.Value;
    }

    private static async Task<int> WriteJsonAsync<T>(TextWriter output, T value)

View on GitHub (pinned to 9b1d7d0eab)

Solutions

  1. Pass 'true' or 'false' (case-insensitive), e.g. '--elevated true'.
  2. Remember 1/0/yes/no/on are rejected by .NET's bool.TryParse.
  3. If you only want the default-on behavior, omit the flag rather than passing a truthy token.

Example fix

// before
unigetui bundle install --elevated yes
// after
unigetui bundle install --elevated true
Defensive patterns

Strategy: validation

Validate before calling

static bool TryNormalizeBool(string? raw, out bool value) =>
    bool.TryParse(raw, out value);

// translate common aliases before calling the CLI:
static string? CanonicalizeBool(string? raw) => raw?.Trim().ToLowerInvariant() switch
{
    "1" or "yes" or "on" or "y" => "true",
    "0" or "no" or "off" or "n" => "false",
    var v => v,
};

Prevention

When it happens

Trigger: Passing '--elevated yes', '--skip-hash 1', '--interactive on', or '--include-installed y' to a bundle install command. The flag is detected by GetOptionalArgument, then bool.TryParse fails.

Common situations: Using 1/0 or yes/no, which many other CLIs accept. Copying values from environment-variable-style configs. Abbreviations like 'y'/'n'.

Related errors


AI-assisted analysis of Devolutions/UniGetUI@9b1d7d0eab (2026-08-13). Data as JSON: /api/errors/d2283a7f00b9aab2. Report an issue: GitHub.