{"record":{"id":"59855e8897801562","repo":"iOfficeAI/OfficeCLI","slug":"invalid-height-value-value-expected-a-fini","errorCode":null,"errorMessage":"Invalid 'height' value: '{value}'. Expected a finite number (row height in points, e.g. 15.75).","messagePattern":"Invalid 'height' value: '(.+?)'\\. Expected a finite number \\(row height in points, e\\.g\\. 15\\.75\\)\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Helpers.cs","lineNumber":137,"sourceCode":"            _ => null\n        };\n\n    // CONSISTENCY(rc-units): Row height is in points in OOXML; this helper\n    // accepts bare numbers (treated as points, backward compat) as well as\n    // unit-qualified \"40pt\", \"40px\", \"1cm\", \"0.5in\" and returns points.\n    internal static double ParseRowHeightPoints(string value)\n    {\n        if (string.IsNullOrWhiteSpace(value))\n            throw new ArgumentException(\"Row height cannot be empty.\");\n        var trimmed = value.Trim();\n        double pts;\n        // Bare number → points (legacy behavior)\n        if (double.TryParse(trimmed, System.Globalization.NumberStyles.Float,\n                System.Globalization.CultureInfo.InvariantCulture, out var bare)\n            && !char.IsLetter(trimmed[^1]))\n        {\n            if (double.IsNaN(bare) || double.IsInfinity(bare))\n                throw new ArgumentException($\"Invalid 'height' value: '{value}'. Expected a finite number (row height in points, e.g. 15.75).\");\n            pts = bare;\n        }\n        else\n        {\n            // Unit-qualified: convert via EMU then back to points.\n            try\n            {\n                var emu = OfficeCli.Core.EmuConverter.ParseEmu(trimmed);\n                pts = emu / EmuConverter.EmuPerPointF;\n            }\n            catch (Exception ex)\n            {\n                throw new ArgumentException($\"Invalid 'height' value: '{value}'. Expected a finite number or unit-qualified value (e.g. 15.75, 40pt, 40px, 1cm, 0.5in).\", ex);\n            }\n        }\n        // DEFERRED(xlsx/row-height-validation) RC2: Excel row height is bounded\n        // [0, 409.5] points. Values outside this range are rejected by Excel at\n        // open time (file silently repaired), so validate at Set time.","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Helpers.cs#L119-L155","documentation":"Thrown by ParseRowHeightPoints when the bare-number branch parsed the input successfully via double.TryParse but the result is NaN or Infinity. double.TryParse accepts 'NaN', 'Infinity', and '-Infinity' under NumberStyles.Float, so this guard explicitly rejects those non-finite sentinel strings before they would corrupt a row height.","triggerScenarios":"Passing height=NaN, height=Infinity, height=-Infinity, or any string that double.TryParse accepts as non-finite (e.g. some locales yield '∞' through upstream transformation).","commonSituations":"A computation upstream divides by zero and the resulting NaN/Infinity is interpolated into the prop string; an LLM emits 'Infinity' as a placeholder; serialization of a default(double)/NaN field.","solutions":["Replace the non-finite value with a concrete finite number (e.g. 15.75 points).","Fix the upstream arithmetic that produced NaN/Infinity (divide-by-zero, overflow) before passing it to the Set path.","Validate with double.IsFinite before constructing the prop value."],"exampleFix":"// before\nvar h = total / count;            // count == 0 -> NaN\nset $\"/Sheet1/row[5] --prop height={h}\";\n\n// after\nvar h = count == 0 ? 15.0 : total / count;\nset $\"/Sheet1/row[5] --prop height={h}\";","handlingStrategy":"validation","validationCode":"if (!double.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var d) || !double.IsFinite(d))\n    throw new ArgumentException($\"Row height must be a finite number, got '{value}'.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter out NaN/Infinity at the source (fix divide-by-zero, overflow).","Use double.IsFinite as the canonical finite check before formatting the prop."],"tags":["excel","validation","row-height","numeric"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}