{"record":{"id":"5a2770d039781465","repo":"iOfficeAI/OfficeCLI","slug":"invalid-overlap-value-expected-integer-100","errorCode":null,"errorMessage":"Invalid overlap: '{value}'. Expected integer (-100 to 100).","messagePattern":"Invalid overlap: '(.+?)'\\. Expected integer \\(-100 to 100\\)\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/Chart/ChartHelper.Setter.cs","lineNumber":1648,"sourceCode":"                        {\n                            // Insert before the first AxisId — mirrors BuildBarChart's\n                            // schema order: [barDirection, barGrouping, varyColors,\n                            // ser*, gapWidth, overlap?, axisId+].\n                            var axisIdEl = barChartEl.GetFirstChild<C.AxisId>();\n                            if (axisIdEl != null)\n                                axisIdEl.InsertBeforeSelf(new C.GapWidth { Val = (ushort)gw });\n                            else\n                                barChartEl.AppendChild(new C.GapWidth { Val = (ushort)gw });\n                        }\n                    }\n                    break;\n                }\n\n                case \"overlap\":\n                {\n                    var plotArea2 = chart.GetFirstChild<C.PlotArea>();\n                    if (plotArea2 == null) { unsupported.Add(key); break; }\n                    if (!int.TryParse(value, out var ov)) throw new ArgumentException($\"Invalid overlap: '{value}'. Expected integer (-100 to 100).\");\n                    if (ov < -100 || ov > 100) throw new ArgumentException($\"Invalid overlap: '{value}'. Valid range is -100 to 100.\");\n                    var overlapBarEls = plotArea2.Elements<OpenXmlCompositeElement>()\n                        .Where(e => e.LocalName.Contains(\"barChart\") || e.LocalName.Contains(\"BarChart\"))\n                        .ToList();\n                    if (overlapBarEls.Count == 0) { unsupported.Add(key); break; }\n                    foreach (var barChart in overlapBarEls)\n                    {\n                        var overlapEl = barChart.GetFirstChild<C.Overlap>();\n                        if (overlapEl != null) overlapEl.Val = (sbyte)ov;\n                        else\n                        {\n                            var gapEl = barChart.GetFirstChild<C.GapWidth>();\n                            if (gapEl != null) gapEl.InsertAfterSelf(new C.Overlap { Val = (sbyte)ov });\n                            else barChart.AppendChild(new C.Overlap { Val = (sbyte)ov });\n                        }\n                    }\n                    break;\n                }","sourceCodeStart":1630,"sourceCodeEnd":1666,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/Chart/ChartHelper.Setter.cs#L1630-L1666","documentation":"Thrown when 'overlap' is not a parseable integer (int.TryParse fails). This is the parse-failure path; a second throw ('Valid range is -100 to 100.') handles integers outside that range. OOXML CT_Overlap is a signed byte (-100..100). Atomic — both checks run before any overlap element is mutated.","triggerScenarios":"SetChartProperties with { [\"overlap\"] = \"50%\" }, \"half\", \"0.5\", or any non-integer token on a bar/column chart.","commonSituations":"Percentage suffix reuse; decimal overlap from a ratio; localized decimal separator.","solutions":["Pass overlap as a plain integer string in -100..100.","Strip '%' and parse to int upstream.","Validate parse and range before calling Set."],"exampleFix":"// before\nSetChartProperties(part, new() { [\"overlap\"] = \"50%\" });\n// after\nSetChartProperties(part, new() { [\"overlap\"] = Math.Clamp(ov, -100, 100).ToString() });","handlingStrategy":"validation","validationCode":"static bool IsValidOverlap(string v, out int ov) =>\n    int.TryParse(v?.Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out ov)\n    && ov >= -100 && ov <= 100;","typeGuard":"static bool IsLegalOverlap(int ov) => ov is >= -100 and <= 100;","tryCatchPattern":"try { SetChartProperties(part, props); }\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"Invalid overlap\"))\n{ /* strip '%', parse, clamp to -100..100, retry */ }","preventionTips":["Send overlap as a plain integer in -100..100, not a percentage.","Validate both parse and range before calling Set.","Use invariant-culture parsing."],"tags":["ooxml","chart","input-validation","bar-chart","csharp"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}