LykosAI/StabilityMatrix · warning · DataValidationException

Pack already exists

Error message

Pack already exists

What it means

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.

Solutions

  1. Choose a unique pack name not already in the ExtensionPacks list.
  2. Delete or rename the existing pack if the duplicate was unintended.
  3. If the duplicate is stale state, reload/refresh the extension packs collection before retrying.

Example fix

// before
if (ExtensionPacks.Any(pack => pack.Name == text)) throw new DataValidationException("Pack already exists");
// after
if (ExtensionPacks.Any(pack => string.Equals(pack.Name, text?.Trim(), StringComparison.OrdinalIgnoreCase)))
    throw new DataValidationException($"Pack '{text}' already exists");
Defensive patterns

Strategy: validation

Validate before calling

var name = promptText?.Trim();
if (name != null && extensionPacks.Any(p => string.Equals(p.Name, name, StringComparison.OrdinalIgnoreCase)))
    return; // duplicate — pick another name

Type guard

bool IsUniquePackName(string? name, IEnumerable<ExtensionPack> packs) =>
    !string.IsNullOrWhiteSpace(name) && packs.All(p => !string.Equals(p.Name, name, StringComparison.OrdinalIgnoreCase));

Try / catch

try { await ShowCreatePackDialog(); }
catch (DataValidationException ex) { ShowWarning(ex.Message); }

Prevention

When it happens

Trigger: Creating an extension pack whose Name matches the Name property of any element already present in ExtensionPacks (exact string equality).

Common situations: 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.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


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

Appendix: source

Thrown at StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageExtensionBrowserViewModel.cs:844

        foreach (var item in SelectedExtensionPackExtensions.ToImmutableArray())
            item.IsSelected = false;
    }

    private (BetterContentDialog dialog, TextBoxField nameField) GetNameEntryDialog()
    {
        var textFields = new TextBoxField[]
        {
            new()
            {
                Label = "Name",
                Validator = text =>
                {
                    if (string.IsNullOrWhiteSpace(text))
                        throw new DataValidationException("Name is required");

                    if (ExtensionPacks.Any(pack => pack.Name == text))
                        throw new DataValidationException("Pack already exists");
                },
            },
        };

        return (DialogHelper.CreateTextEntryDialog("Pack Name", "", textFields), textFields[0]);
    }

    private async Task<bool> BeforeInstallCheck()
    {
        if (
            !settingsManager.Settings.SeenTeachingTips.Contains(
                Core.Models.Settings.TeachingTip.PackageExtensionsInstallNotice
            )
        )
        {
            var dialog = new BetterContentDialog
            {
                Title = "Installing Extensions",

View on GitHub (pinned to af93d6ef57)