LykosAI/StabilityMatrix · error · InvalidOperationException

Definition: ' ' has options, it must have exactly 1 option…

Error message

Definition: '{definition.Name}' has {definition.Options.Count} options, it must have exactly 1 option for non-bool types

What it means

LaunchOptionsDialogViewModel.Initialize builds cards from launch option definitions and enforces that every non-Bool definition has exactly one Option (a single choice value). Multi-option lists only make sense for Bool flags, so any other shape is treated as a malformed definition and throws immediately at dialog construction.

Solutions

  1. Fix the package's launch option definition so non-Bool types have exactly one Options entry.
  2. If the type was meant to be a toggle with multiple options, change Type to LaunchOptionType.Bool.
  3. Check for package updates where the author corrected the definition.
  4. Report the malformed definition to the package maintainer if it ships that way.

Example fix

// before
- name: Mode
  type: String
  options: [fast, safe]   # invalid: 2 options on non-bool
// after
- name: Mode
  type: String
  options: [fast]
Defensive patterns

Strategy: validation

Validate before calling

foreach (var d in definitions)
    if (d.Type != LaunchOptionType.Bool && d.Options.Count != 1)
        throw new InvalidOperationException($"{d.Name}: non-bool options must have exactly 1 option");

Type guard

static bool IsValidOptionDefinition(LaunchOptionDefinition d) =>
    d.Type == LaunchOptionType.Bool || d.Options.Count == 1;

Try / catch

try { viewModel.Initialize(definitions); }
catch (InvalidOperationException ex) when (ex.Message.Contains("exactly 1 option"))
{
    logger.Warning(ex, "Malformed launch option definition; skipping dialog");
    // filter out or fix the offending definition before retrying
}

Prevention

When it happens

Trigger: Opening the launch options dialog while a package's launch option definition (from a package Mod/Config yaml) declares Type String/Multiple/etc. with zero or more than one entry in Options.

Common situations: A community package author wrote a launch option with several options for a non-bool type; a package yaml was hand-edited incorrectly; an older package definition predates a schema change and now violates the rule.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12). Data as JSON: /api/errors/c6236ec6d9c8cdcc. Report an issue: GitHub.

Appendix: source

Thrown at StabilityMatrix/ViewModels/LaunchOptionsDialogViewModel.cs:84

        foreach (var card in Cards)
        {
            launchArgs.AddRange(card.Options);
        }
        return launchArgs;
    }

    public void Initialize(IEnumerable<LaunchOptionDefinition> definitions, IEnumerable<LaunchOption> launchArgs)
    {
        Clear();
        // During card creation, store dict of options with initial values
        var initialOptions = new Dictionary<string, object>();
        // Create cards
        foreach (var definition in definitions)
        {
            // Check that non-bool types have exactly one option
            if (definition.Type != LaunchOptionType.Bool && definition.Options.Count != 1)
            {
                throw new InvalidOperationException(
                    $"Definition: '{definition.Name}' has {definition.Options.Count} options," +
                    $" it must have exactly 1 option for non-bool types");
            }
            // Store initial values
            if (definition.InitialValue != null)
            {
                // For bool types, initial value can be string (single/multiple options) or bool (single option)
                if (definition.Type == LaunchOptionType.Bool)
                {
                    // For single option, check bool
                    if (definition.Options.Count == 1 && definition.InitialValue is bool boolValue)
                    {
                        initialOptions[definition.Options.First()] = boolValue;
                    }
                    else
                    {
                        // For single/multiple options (string only)
                        var option = definition.Options.FirstOrDefault(opt => opt.Equals(definition.InitialValue));

View on GitHub (pinned to af93d6ef57)