{"record":{"id":"f305e99421cc11dd","repo":"LykosAI/StabilityMatrix","slug":"width-must-be-a-positive-integer","errorCode":null,"errorMessage":"Width must be a positive integer","messagePattern":"Width must be a positive integer","errorType":"validation","errorClass":"DataValidationException","httpStatus":null,"severity":"warning","filePath":"StabilityMatrix.Avalonia/ViewModels/Settings/InferenceSettingsViewModel.cs","lineNumber":301,"sourceCode":"        );\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\",\n            },\n        };\n","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Avalonia/ViewModels/Settings/InferenceSettingsViewModel.cs#L283-L319","documentation":"This DataValidationException is thrown by the Width field's Validator in the 'Add Favorite Dimensions' text-entry dialog in InferenceSettingsViewModel. The library throws it because the entered width is either not parseable as an integer or is <= 0; only positive integers are accepted for image dimensions.","triggerScenarios":"User opens AddRow's 'Add Favorite Dimensions' dialog and types a non-numeric string (e.g. 'abc', '10.5') or a zero/negative number (e.g. '0', '-512') into the Width field.","commonSituations":"Pasting a dimension pair into the wrong field, typing fractional sizes copied from other tools, entering 0 intending 'default'.","solutions":["Enter a positive whole number such as 1024 in the Width field","If the value came from another tool, round it to a whole integer","Do not leave the field blank; 'Width is required' covers empty input"],"exampleFix":"// before\nvar widthText = \"-512\";\n// after\nvar widthText = \"512\"; // positive integer only","handlingStrategy":"validation","validationCode":"bool isValidWidth(string s) => int.TryParse(s, out var w) && w > 0;","typeGuard":"bool IsValidDimension(string s) => int.TryParse(s, out var v) && v > 0;","tryCatchPattern":"try { dialog.SaveDimensions(); } catch (DataValidationException ex) { ShowFieldError(\"Width\", ex.Message); }","preventionTips":["Always enter whole positive pixel values","Do not paste values with units or decimals","Fill both Width and Height fields"],"tags":["validation","user-input","wpf","csharp"],"backgroundTag":"invalid-argument-value","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}