{"record":{"id":"406b204c2a232e3c","repo":"LykosAI/StabilityMatrix","slug":"definition-definition-name-has-initialvalue-of-definition","errorCode":null,"errorMessage":"Definition '{definition.Name}' has InitialValue of '{definition.InitialValue}', but it was not found in options: '{string.Join(\",\", definition.Options)}'","messagePattern":"Definition '(.+?)' has InitialValue of '(.+?)', but it was not found in options: '(.+?)'","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix/ViewModels/LaunchOptionsDialogViewModel.cs","lineNumber":105,"sourceCode":"            }\n            // Store initial values\n            if (definition.InitialValue != null)\n            {\n                // For bool types, initial value can be string (single/multiple options) or bool (single option)\n                if (definition.Type == LaunchOptionType.Bool)\n                {\n                    // For single option, check bool\n                    if (definition.Options.Count == 1 && definition.InitialValue is bool boolValue)\n                    {\n                        initialOptions[definition.Options.First()] = boolValue;\n                    }\n                    else\n                    {\n                        // For single/multiple options (string only)\n                        var option = definition.Options.FirstOrDefault(opt => opt.Equals(definition.InitialValue));\n                        if (option == null)\n                        {\n                            throw new InvalidOperationException(\n                                $\"Definition '{definition.Name}' has InitialValue of '{definition.InitialValue}', but it was not found in options:\" +\n                                $\" '{string.Join(\",\", definition.Options)}'\");\n                        }\n                        initialOptions[option] = true;\n                    }\n                }\n                else\n                {\n                    // Otherwise store initial value for first option\n                    initialOptions[definition.Options.First()] = definition.InitialValue;\n                }\n            }\n            Cards.Add(new LaunchOptionCard(definition));\n        }\n        // Load launch args\n        var launchArgsDict = launchArgs.ToDictionary(launchArg => launchArg.Name);\n        foreach (var card in Cards)\n        {","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix/ViewModels/LaunchOptionsDialogViewModel.cs#L87-L123","documentation":"Initialize validates that a definition's saved InitialValue actually matches one of its declared Options for single/multiple select types. If the persisted value is not present in the option list (FirstOrDefault returns null), the dialog cannot represent the stored choice and throws with the definition name, value, and option list.","triggerScenarios":"Opening the launch options dialog when a definition's InitialValue (from saved settings or package defaults) is not string-equal to any entry in definition.Options.","commonSituations":"Package updated its option list (renamed or removed choices) while the user's saved InitialValue still holds the old value; case/whitespace differences between the saved value and the options; hand-edited settings file referencing a nonexistent option.","solutions":["Update the saved launch option value to one that exists in the definition's Options list.","Update or reinstall the package so the definition's Options include the saved value (or reset its InitialValue).","Check for case/whitespace mismatches between the stored value and the option strings.","Clear the stale setting for that option to fall back to the definition default."],"exampleFix":"// before (saved value missing from new options)\n\"initialValue\": \"fast\", \"options\": [\"turbo\", \"safe\"]\n// after\n\"initialValue\": \"turbo\", \"options\": [\"turbo\", \"safe\"]","handlingStrategy":"validation","validationCode":"if (d.InitialValue is string v && !d.Options.Contains(v))\n    d.InitialValue = d.Options.FirstOrDefault() ?? throw new InvalidOperationException($\"{d.Name}: InitialValue '{v}' not in options\");","typeGuard":"static bool InitialValueInOptions(LaunchOptionDefinition d) =>\n    d.InitialValue is null || d.Options.Any(o => o.Equals(d.InitialValue));","tryCatchPattern":"try { viewModel.Initialize(definitions); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"was not found in options\"))\n{\n    logger.Warning(ex, \"Stale InitialValue; resetting to default\");\n    // reset the saved value and re-initialize\n}","preventionTips":["When package options change, migrate or reset saved InitialValues.","Compare values case-insensitively/trimmed when matching saved values.","Validate settings files against current package definitions at load.","Provide a 'reset to defaults' path for corrupted option state."],"tags":["launch-options","validation","state"],"backgroundTag":"invalid-config-value","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}