LykosAI/StabilityMatrix · warning · DataValidationException

Resources.Validation_PackageNameCannotBeEmpty

Error message

Resources.Validation_PackageNameCannotBeEmpty

What it means

In PackageCardViewModel's package rename flow, a TextBoxField.Validator lambda validates the new package name typed into the rename dialog. When the text is null/whitespace it throws DataValidationException(Resources.Validation_PackageNameCannotBeEmpty); the dialog framework catches this and shows the localized validation message instead of performing the rename. The bracketed resource key is the thrown message because DataValidationException is keyed on the localized string resource.

Solutions

  1. Type a non-empty package name in the rename dialog before confirming.
  2. Trim the input and re-check: the name must contain at least one non-whitespace character and must not collide with an existing package directory (the validator's second check).
  3. Cancel the dialog if you don't want to rename; the original name is kept.
  4. If validating programmatically, mirror the validator: reject string.IsNullOrWhiteSpace(text) before calling DirectoryPath.MoveToAsync.

Example fix

// before (throws inside validator)
if (string.IsNullOrWhiteSpace(text))
    throw new DataValidationException(Resources.Validation_PackageNameCannotBeEmpty);
// after (caller-side pre-check)
if (!string.IsNullOrWhiteSpace(newName) && !directoryPath.Exists)
    await existingPath.MoveToAsync(new DirectoryPath(parentDir, newName));
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrWhiteSpace(newName))
    return; // don't submit the rename dialog
var target = new DirectoryPath(Path.GetDirectoryName(package.FullPath!)!, newName);
if (target.Exists) { /* name collides with existing package */ }

Type guard

bool IsValidPackageName(string? name) => !string.IsNullOrWhiteSpace(name);

Try / catch

var result = await DialogHelper.GetTextEntryDialogResultAsync(field, ...);
// validator throws DataValidationException internally; the dialog surfaces it
if (result.Result == ContentDialogResult.Primary && field.IsValid)
    await PerformRename(field.Text);

Prevention

When it happens

Trigger: Submitting (clicking Rename/OK in GetTextEntryDialogResultAsync) the rename dialog with an empty or whitespace-only display name — e.g. the user cleared the text field, pasted only spaces, or accepted the dialog before typing anything.

Common situations: User accidentally deletes the existing name before confirming; pasting a name consisting only of whitespace/newlines; automation or UI testing that submits the dialog with an empty TextBox; a renamed display name identical to blank after trimming.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageCardViewModel.cs:890

    }

    [RelayCommand]
    private async Task Rename()
    {
        if (Package is null || IsUnknownPackage)
            return;

        var currentName = Package.DisplayName ?? Package.PackageName ?? string.Empty;
        var field = new TextBoxField
        {
            Label = Resources.Label_DisplayName,
            Text = currentName,
            Watermark = Resources.Watermark_EnterPackageName,
            Validator = text =>
            {
                if (string.IsNullOrWhiteSpace(text))
                {
                    throw new DataValidationException(Resources.Validation_PackageNameCannotBeEmpty);
                }

                var directoryPath = new DirectoryPath(Path.GetDirectoryName(Package.FullPath!)!, text);
                if (directoryPath.Exists)
                {
                    throw new DataValidationException(
                        string.Format(Resources.ValidationError_PackageExists, text)
                    );
                }
            },
        };

        var result = await DialogHelper.GetTextEntryDialogResultAsync(
            field,
            string.Format(Resources.Description_RenamePackage, currentName)
        );

        if (result.Result == ContentDialogResult.Primary && field.IsValid && field.Text != currentName)

View on GitHub (pinned to af93d6ef57)