{"record":{"id":"b7bfff72289d7058","repo":"LykosAI/StabilityMatrix","slug":"file-name-is-required","errorCode":null,"errorMessage":"File name is required","messagePattern":"File name is required","errorType":"validation","errorClass":"DataValidationException","httpStatus":null,"severity":"warning","filePath":"StabilityMatrix.Avalonia/ViewModels/CheckpointManager/CheckpointFileViewModel.cs","lineNumber":350,"sourceCode":"        await modelIndexService.RemoveModelAsync(CheckpointFile);\n    }\n\n    [RelayCommand]\n    private async Task RenameAsync()\n    {\n        // Parent folder path\n        var parentPath =\n            Path.GetDirectoryName((string?)CheckpointFile.GetFullPath(settingsManager.ModelsDirectory)) ?? \"\";\n\n        var textFields = new TextBoxField[]\n        {\n            new()\n            {\n                Label = \"File name\",\n                Validator = text =>\n                {\n                    if (string.IsNullOrWhiteSpace(text))\n                        throw new DataValidationException(\"File name is required\");\n\n                    if (File.Exists(Path.Combine(parentPath, text)))\n                        throw new DataValidationException(\"File name already exists\");\n                },\n                Text = CheckpointFile.FileName,\n            },\n        };\n\n        var dialog = DialogHelper.CreateTextEntryDialog(\"Rename Model\", \"\", textFields);\n\n        if (await dialog.ShowAsync() == ContentDialogResult.Primary)\n        {\n            var name = textFields[0].Text;\n            var nameNoExt = Path.GetFileNameWithoutExtension(name);\n            var originalNameNoExt = Path.GetFileNameWithoutExtension(CheckpointFile.FileName);\n            // Rename file in OS\n            try\n            {","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Avalonia/ViewModels/CheckpointManager/CheckpointFileViewModel.cs#L332-L368","documentation":"In CheckpointFileViewModel.RenameAsync, the rename dialog's Validator throws DataValidationException(\"File name is required\") when the user submits an empty or whitespace-only name. The dialog blocks the rename until a valid non-empty name is entered.","triggerScenarios":"Submitting the 'Rename Model' text-entry dialog (launched from RenameAsync on a CheckpointFileViewModel) with an empty string or only whitespace in the 'File name' field.","commonSituations":"Pressing Enter/clicking OK without typing a name; accidentally clearing the pre-filled Text (CheckpointFile.FileName) before confirming.","solutions":["Type a non-empty file name (including its extension) in the dialog and confirm","Cancel the dialog if you did not intend to rename","If triggered programmatically, pass the existing CheckpointFile.FileName as the default Text so empty submissions cannot occur"],"exampleFix":"// before\nText = CheckpointFile.FileName, // user may clear it\n\n// after\nText = CheckpointFile.FileName,\nValidator = text =>\n{\n    if (string.IsNullOrWhiteSpace(text))\n        throw new DataValidationException(\"File name is required\");\n    if (!Path.HasExtension(text) && Path.HasExtension(CheckpointFile.FileName))\n        text = text + Path.GetExtension(CheckpointFile.FileName); // preserve extension\n    if (File.Exists(Path.Combine(parentPath, text)))\n        throw new DataValidationException(\"File name already exists\");\n}","handlingStrategy":"validation","validationCode":"// Validate before confirming the rename\nif (string.IsNullOrWhiteSpace(newName))\n    throw new DataValidationException(\"File name is required\");","typeGuard":"bool IsValidFileName(string? name) =>\n    !string.IsNullOrWhiteSpace(name) && name.IndexOfAny(Path.GetInvalidFileNameChars()) < 0;","tryCatchPattern":"try\n{\n    await checkpointFileVm.RenameAsync();\n}\ncatch (DataValidationException ex) when (ex.Message == \"File name is required\")\n{\n    // Dialog already surfaces this; log for telemetry only\n    Logger.Debug(\"Rename aborted: empty file name\");\n}","preventionTips":["Always pre-fill the rename dialog with the current file name (Text = CheckpointFile.FileName)","Keep the extension when typing a new name","Do not clear the input field before confirming","Cancel the dialog if no rename is intended"],"tags":["validation","empty-input","rename","dialog"],"backgroundTag":"empty-required-field","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"}