{"record":{"id":"9357777b10180fcf","repo":"LykosAI/StabilityMatrix","slug":"width-is-required","errorCode":null,"errorMessage":"Width is required","messagePattern":"Width is required","errorType":"validation","errorClass":"DataValidationException","httpStatus":null,"severity":"warning","filePath":"StabilityMatrix.Avalonia/ViewModels/Settings/InferenceSettingsViewModel.cs","lineNumber":298,"sourceCode":"            $\"Imported {sourceFile.Name}\",\n            $\"The {sourceFile.Name} file has been imported.\",\n            NotificationType.Success\n        );\n    }\n\n    [RelayCommand]\n    private async Task AddRow()\n    {\n        // FavoriteDimensions.Add(string.Empty);\n        var textFields = new TextBoxField[]\n        {\n            new()\n            {\n                Label = \"Width\",\n                Validator = text =>\n                {\n                    if (string.IsNullOrWhiteSpace(text))\n                        throw new DataValidationException(\"Width is required\");\n\n                    if (!int.TryParse(text, out var width) || width <= 0)\n                        throw new DataValidationException(\"Width must be a positive integer\");\n                },\n                Watermark = \"1024\",\n            },\n            new()\n            {\n                Label = \"Height\",\n                Validator = text =>\n                {\n                    if (string.IsNullOrWhiteSpace(text))\n                        throw new DataValidationException(\"Height is required\");\n\n                    if (!int.TryParse(text, out var height) || height <= 0)\n                        throw new DataValidationException(\"Height must be a positive integer\");\n                },\n                Watermark = \"1024\",","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Avalonia/ViewModels/Settings/InferenceSettingsViewModel.cs#L280-L316","documentation":"AddRow in InferenceSettingsViewModel shows a text-entry dialog for a new inference row whose 'Width' field validator throws DataValidationException('Width is required') when the input is null or whitespace. It ensures a width value is supplied before the companion positive-integer check runs.","triggerScenarios":"Submitting the Add Row dialog (InferenceSettingsViewModel.cs:298) leaving the Width field empty or whitespace-only.","commonSituations":"Clicking OK without typing a value; clearing the field intending to cancel; paste of whitespace; typing non-numeric text which triggers the sibling 'Width must be a positive integer' error instead.","solutions":["Enter a positive integer width (e.g. 1024) in the field before confirming.","Use digits only; the follow-up check rejects zero, negatives, and non-numeric text.","If adding rows programmatically, pass a pre-validated integer-as-string."],"exampleFix":"// before\nif (string.IsNullOrWhiteSpace(text)) throw new DataValidationException(\"Width is required\");\n// after\nvar trimmed = text?.Trim();\nif (string.IsNullOrEmpty(trimmed)) throw new DataValidationException(\"Width is required\");\nif (!int.TryParse(trimmed, out var width) || width <= 0)\n    throw new DataValidationException(\"Width must be a positive integer\");","handlingStrategy":"validation","validationCode":"bool IsValidWidth(string? s) =>\n    int.TryParse(s?.Trim(), out var w) && w > 0;\n// only submit the dialog when IsValidWidth(widthText)","typeGuard":"bool TryParsePositiveInt(string? s, out int value) =>\n    int.TryParse(s?.Trim(), out value) && value > 0;","tryCatchPattern":"try { await viewModel.AddRow(); }\ncatch (DataValidationException ex) { SetFieldError(ex.Message); }","preventionTips":["Enter a positive integer in the Width field before confirming.","Use numeric-only input (the watermark suggests 1024).","Keep OK disabled until both width and any companion fields validate."],"tags":["validation","input","settings"],"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"}