{"record":{"id":"7ec1cebe14495df5","repo":"SubtitleEdit/subtitleedit","slug":"resolution-input-is-invalid-width-and-height","errorCode":null,"errorMessage":"Resolution '{input}' is invalid. Width and height must be positive integers.","messagePattern":"Resolution '(.+?)' is invalid\\. Width and height must be positive integers\\.","errorType":"validation","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"src/seconv/Core/ResolutionParser.cs","lineNumber":32,"sourceCode":"        {\n            throw new FormatException(\"Resolution is empty.\");\n        }\n\n        var s = input.Trim();\n        var idx = s.IndexOfAny(['x', 'X']);\n        if (idx <= 0 || idx == s.Length - 1)\n        {\n            throw new FormatException($\"Resolution '{input}' is invalid. Expected WIDTHxHEIGHT, e.g. 1920x1080.\");\n        }\n\n        var wPart = s[..idx];\n        var hPart = s[(idx + 1)..];\n\n        if (!int.TryParse(wPart, NumberStyles.None, CultureInfo.InvariantCulture, out var w) ||\n            !int.TryParse(hPart, NumberStyles.None, CultureInfo.InvariantCulture, out var h) ||\n            w <= 0 || h <= 0)\n        {\n            throw new FormatException($\"Resolution '{input}' is invalid. Width and height must be positive integers.\");\n        }\n\n        return (w, h);\n    }\n}\n","sourceCodeStart":14,"sourceCodeEnd":38,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/seconv/Core/ResolutionParser.cs#L14-L38","documentation":"Thrown by ResolutionParser.Parse when the WIDTHxHEIGHT structure is valid (separator present) but either side fails `int.TryParse` (NumberStyles.None — no sign/decimal) or parses to a non-positive value. The tuple requires two positive integers; negatives, decimals, letters, or zero all fail.","triggerScenarios":"Calling `ResolutionParser.Parse(input)` with values like '1920x1080.0', '-1x1080', '1920x0', '1920xabc', ' 1920 x 1080 ' (internal spaces break int.TryParse of the substring).","commonSituations":"Including a decimal/fractional resolution; a leading sign; embedded spaces between number and separator; scientific notation; copy-paste introducing a non-breaking space inside a number.","solutions":["Use two plain positive integers separated by 'x': `1920x1080`.","Remove spaces, commas, or signs from either dimension.","Round fractional values to the nearest integer (resolutions are integral pixel counts).","Confirm there are no hidden non-breaking spaces (U+00A0) — retype the value."],"exampleFix":"# before\nseconv in.sup out.bdnxml --resolution=1920x1080.5\n# after\nseconv in.sup out.bdnxml --resolution=1920x1080","handlingStrategy":"validation","validationCode":"var parts = input.Split('x', 'X');\nif (parts.Length != 2 ||\n    !int.TryParse(parts[0], NumberStyles.None, CultureInfo.InvariantCulture, out var w) ||\n    !int.TryParse(parts[1], NumberStyles.None, CultureInfo.InvariantCulture, out var h) ||\n    w <= 0 || h <= 0)\n    throw new ArgumentException(\"Width and height must be positive integers\");","typeGuard":"static bool AreDimensionsPositiveIntegers(string? s)\n{\n    if (string.IsNullOrWhiteSpace(s)) return false;\n    var p = s.Split('x', 'X');\n    return p.Length == 2\n        && int.TryParse(p[0], NumberStyles.None, CultureInfo.InvariantCulture, out var w)\n        && int.TryParse(p[1], NumberStyles.None, CultureInfo.InvariantCulture, out var h)\n        && w > 0 && h > 0;\n}","tryCatchPattern":"try { var res = ResolutionParser.Parse(input); }\ncatch (FormatException ex) when (ex.Message.Contains(\"must be positive integers\"))\n{\n    // round/clamp or reprompt\n}","preventionTips":["Strip whitespace and thousands separators before parsing.","Reject non-integer inputs at arg-parse time.","Reject zero/negative dimensions explicitly."],"tags":["cli","parsing","resolution","integer-validation"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}