{"record":{"id":"893a85b6309f9663","repo":"iOfficeAI/OfficeCLI","slug":"invalid-spacing-value-value-value-too-large","errorCode":null,"errorMessage":"Invalid spacing value '{value}'. Value too large — exceeds maximum representable spacing (~{int.MaxValue / 100.0}pt).","messagePattern":"Invalid spacing value '(.+?)'\\. Value too large — exceeds maximum representable spacing \\(~(.+?)pt\\)\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/SpacingConverter.cs","lineNumber":98,"sourceCode":"    //  spaceBefore / spaceAfter  →  PPT hundredths-of-a-point\n    // ────────────────────────────────────────────────────────────────\n\n    /// <summary>\n    /// Parse a spacing value (spaceBefore/spaceAfter) to PPT hundredths-of-a-point (int).\n    /// Accepts: \"12pt\", \"0.5cm\", \"0.5in\", or bare number (treated as points for backward compat).\n    /// </summary>\n    public static int ParsePptSpacing(string value)\n    {\n        var points = ParseSpacingToPoints(value, bareIsPoints: true);\n        if (points < 0)\n            throw new ArgumentException($\"Invalid spacing value '{value}'. Spacing must be non-negative.\");\n        // BUG-R7-03: PPT stores spaceBefore/spaceAfter in hundredths of a point\n        // as a 32-bit signed integer (CT_TextSpacing). Compute in 64-bit and\n        // reject values that would silently overflow on cast — the symptom was\n        // 999999999pt clamping to int.MaxValue/100 ≈ 21474836.47pt readback.\n        var hundredths = (long)Math.Round(points * 100);\n        if (hundredths > int.MaxValue)\n            throw new ArgumentException(\n                $\"Invalid spacing value '{value}'. Value too large — exceeds maximum representable spacing (~{int.MaxValue / 100.0}pt).\");\n        return (int)hundredths;\n    }\n\n    /// <summary>\n    /// Parse a length value to points, allowing negative values. Accepts\n    /// unit-qualified \"12pt\", \"0.5cm\", \"0.5in\", \"-1cm\", \"-12pt\", or a bare\n    /// signed number (treated as points). Used for PPTX paragraph indent\n    /// which permits hanging-indent style negatives. CONSISTENCY(pptx-bare-as-points).\n    /// </summary>\n    public static double ParsePointsSigned(string value)\n    {\n        return ParseSpacingToPointsSigned(value, bareIsPoints: true);\n    }\n\n    /// <summary>\n    /// Parse a length value to points. Accepts unit-qualified \"12pt\", \"0.5cm\",\n    /// \"0.5in\" or bare number (treated as points). Used for XLSX shape margin","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/SpacingConverter.cs#L80-L116","documentation":"Thrown by ParsePptSpacing (BUG-R7-03) when the value, converted to hundredths of a point, exceeds int.MaxValue. CT_TextSpacing stores hundredths in a 32-bit signed int (~21,474,836.47pt max). Without this guard a huge value silently overflowed/clamped on cast, producing a wrong readback. ArgumentException naming the approximate maximum.","triggerScenarios":"Passing an astronomically large spacing value such as '999999999pt' or '50000000pt' to a PPT spacing slot. Computation is done in 64-bit then compared to int.MaxValue.","commonSituations":"A script bug feeds an unchecked or unit-confused number (e.g. twips passed where points expected, magnifying the value), or a copied large table cell-spacing value is applied to paragraph spacing.","solutions":["Use a physically reasonable spacing value (PPT paragraphs rarely exceed a few hundred points).","Check the units — ensure you are passing points/cm/in, not an inflated raw integer.","Validate the value is under ~21,474,836pt before calling."],"exampleFix":"// before\nset shape text spacing spaceBefore=999999999pt\n// after\nset shape text spacing spaceBefore=12pt","handlingStrategy":"validation","validationCode":"const double MaxPptPt = int.MaxValue / 100.0; // ~21,474,836.47pt\nvar pts = SpacingConverter.ParsePoints(value);\nif (pts > MaxPptPt) throw new ArgumentException($\"Value too large for PPT spacing: {value}\");","typeGuard":null,"tryCatchPattern":"try { var hundredths = SpacingConverter.ParsePptSpacing(value); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Value too large\"))\n{ /* clamp/repair the source value; check unit confusion */ }","preventionTips":["Reject absurdly large spacing values before calling.","Verify units — points vs twips confusion inflates values 20x.","PPT paragraph spacing rarely exceeds a few hundred points."],"tags":["spacing","powerpoint","overflow","argument","validation"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}