Devolutions/UniGetUI · error · InvalidOperationException

The value supplied to --enabled must be either true or false

Error message

The value supplied to --enabled must be either true or false.

What it means

Thrown by IpcCliCommandRunner.BuildSettingRequest when the '--enabled' flag value cannot be parsed by bool.TryParse. This is specific to the set-setting CLI path, which accepts only .NET bool tokens (True/False case-insensitive, and '1'/'0' are NOT accepted by bool.TryParse).

Source

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

    {
        return new IpcBundleInstallRequest
        {
            IncludeInstalled = GetOptionalBoolArgument(args, "--include-installed"),
            Elevated = GetOptionalBoolArgument(args, "--elevated"),
            Interactive = GetOptionalBoolArgument(args, "--interactive"),
            SkipHash = GetOptionalBoolArgument(args, "--skip-hash"),
        };
    }

    private static IpcSettingValueRequest BuildSettingRequest(IReadOnlyList<string> args)
    {
        bool? enabled = null;
        string? enabledValue = GetOptionalArgument(args, "--enabled");
        if (enabledValue is not null)
        {
            if (!bool.TryParse(enabledValue, out bool parsedEnabled))
            {
                throw new InvalidOperationException(
                    "The value supplied to --enabled must be either true or false."
                );
            }

            enabled = parsedEnabled;
        }

        return new IpcSettingValueRequest
        {
            SettingKey = GetRequiredArgument(
                args,
                "--key",
                "This command requires --key."
            ),
            Enabled = enabled,
            Value = GetOptionalArgument(args, "--value"),
        };
    }

View on GitHub (pinned to 9b1d7d0eab)

Solutions

  1. Pass '--enabled true' or '--enabled false' (case-insensitive).
  2. Note that '1'/'0'/'yes'/'on' are rejected; spell the word out.
  3. Omit --enabled entirely if you only want to set a string --value.

Example fix

// before
unigetui set-setting --key AutoCheckUpdates --enabled 1
// after
unigetui set-setting --key AutoCheckUpdates --enabled true
Defensive patterns

Strategy: validation

Validate before calling

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

// reject '1/0/yes/no' explicitly in the UI before calling set-setting.

Prevention

When it happens

Trigger: Running 'unigetui set-setting --key X --enabled yes', '--enabled 1', '--enabled on', or '--enabled enable'. bool.TryParse only accepts 'True'/'False' (any case) and null.

Common situations: Shell users passing 1/0 or yes/no, common in other CLIs. Copying a value from a YAML/config that uses 'on'. Locale-influenced booleans.

Related errors


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