{"record":{"id":"55fa674264a85e0c","repo":"LykosAI/StabilityMatrix","slug":"pack-already-exists","errorCode":null,"errorMessage":"Pack already exists","messagePattern":"Pack already exists","errorType":"validation","errorClass":"DataValidationException","httpStatus":null,"severity":"warning","filePath":"StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageExtensionBrowserViewModel.cs","lineNumber":844,"sourceCode":"\n        foreach (var item in SelectedExtensionPackExtensions.ToImmutableArray())\n            item.IsSelected = false;\n    }\n\n    private (BetterContentDialog dialog, TextBoxField nameField) GetNameEntryDialog()\n    {\n        var textFields = new TextBoxField[]\n        {\n            new()\n            {\n                Label = \"Name\",\n                Validator = text =>\n                {\n                    if (string.IsNullOrWhiteSpace(text))\n                        throw new DataValidationException(\"Name is required\");\n\n                    if (ExtensionPacks.Any(pack => pack.Name == text))\n                        throw new DataValidationException(\"Pack already exists\");\n                },\n            },\n        };\n\n        return (DialogHelper.CreateTextEntryDialog(\"Pack Name\", \"\", textFields), textFields[0]);\n    }\n\n    private async Task<bool> BeforeInstallCheck()\n    {\n        if (\n            !settingsManager.Settings.SeenTeachingTips.Contains(\n                Core.Models.Settings.TeachingTip.PackageExtensionsInstallNotice\n            )\n        )\n        {\n            var dialog = new BetterContentDialog\n            {\n                Title = \"Installing Extensions\",","sourceCodeStart":826,"sourceCodeEnd":862,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageExtensionBrowserViewModel.cs#L826-L862","documentation":"The same Name field validator in PackageExtensionBrowserViewModel also throws DataValidationException('Pack already exists') when the entered name duplicates an existing item in ExtensionPacks. Extension pack names are treated as unique identifiers within the current package's extension pack collection.","triggerScenarios":"Creating an extension pack whose Name matches the Name property of any element already present in ExtensionPacks (exact string equality).","commonSituations":"Reusing a pack name created earlier in the same session; case-sensitive duplicates like 'MyPack' vs 'mypack' may pass or fail depending on intended uniqueness semantics; re-running the create flow after a partially completed creation.","solutions":["Choose a unique pack name not already in the ExtensionPacks list.","Delete or rename the existing pack if the duplicate was unintended.","If the duplicate is stale state, reload/refresh the extension packs collection before retrying."],"exampleFix":"// before\nif (ExtensionPacks.Any(pack => pack.Name == text)) throw new DataValidationException(\"Pack already exists\");\n// after\nif (ExtensionPacks.Any(pack => string.Equals(pack.Name, text?.Trim(), StringComparison.OrdinalIgnoreCase)))\n    throw new DataValidationException($\"Pack '{text}' already exists\");","handlingStrategy":"validation","validationCode":"var name = promptText?.Trim();\nif (name != null && extensionPacks.Any(p => string.Equals(p.Name, name, StringComparison.OrdinalIgnoreCase)))\n    return; // duplicate — pick another name","typeGuard":"bool IsUniquePackName(string? name, IEnumerable<ExtensionPack> packs) =>\n    !string.IsNullOrWhiteSpace(name) && packs.All(p => !string.Equals(p.Name, name, StringComparison.OrdinalIgnoreCase));","tryCatchPattern":"try { await ShowCreatePackDialog(); }\ncatch (DataValidationException ex) { ShowWarning(ex.Message); }","preventionTips":["List existing pack names in the dialog so users avoid collisions.","Compare names case-insensitively to prevent near-duplicates.","Refresh the packs collection before creating to avoid stale uniqueness data."],"tags":["validation","uniqueness","dialog"],"backgroundTag":"file-already-exists","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"}