{"record":{"id":"3cbb9b0907f2efb4","repo":"iOfficeAI/OfficeCLI","slug":"invalid-axispos-value-value-valid-top-bo","errorCode":null,"errorMessage":"Invalid 'axisPos' value: '{value}'. Valid: top, bottom, left, right.","messagePattern":"Invalid 'axisPos' value: '(.+?)'\\. Valid: top, bottom, left, right\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/Chart/ChartHelper.Setter.cs","lineNumber":1888,"sourceCode":"                    };\n                    foreach (var ax in plotArea2.Elements<C.ValueAxis>().Where(a => !IsDeletedAxis(a)))\n                    { ax.RemoveAllChildren<C.TickLabelPosition>(); InsertAxisChildInOrder(ax, new C.TickLabelPosition { Val = tlPos }); }\n                    foreach (var ax in plotArea2.Elements<C.CategoryAxis>().Where(a => !IsDeletedAxis(a)))\n                    { ax.RemoveAllChildren<C.TickLabelPosition>(); InsertAxisChildInOrder(ax, new C.TickLabelPosition { Val = tlPos }); }\n                    break;\n                }\n\n                case \"axisposition\" or \"axispos\":\n                {\n                    var plotArea2 = chart.GetFirstChild<C.PlotArea>();\n                    if (plotArea2 == null) { unsupported.Add(key); break; }\n                    var axPos = value.ToLowerInvariant() switch\n                    {\n                        \"top\" or \"t\" => C.AxisPositionValues.Top,\n                        \"bottom\" or \"b\" => C.AxisPositionValues.Bottom,\n                        \"left\" or \"l\" => C.AxisPositionValues.Left,\n                        \"right\" or \"r\" => C.AxisPositionValues.Right,\n                        _ => throw new ArgumentException($\"Invalid 'axisPos' value: '{value}'. Valid: top, bottom, left, right.\")\n                    };\n                    foreach (var ax in plotArea2.Elements<C.CategoryAxis>())\n                    {\n                        ax.RemoveAllChildren<C.AxisPosition>();\n                        // CONSISTENCY(chart/axis-schema-order): axPos must sit\n                        // immediately after delete in the CT_*Ax prefix; an\n                        // AppendChild lands it at the tail and PowerPoint silently\n                        // honors a stale axPos while OpenXmlValidator rejects the\n                        // file with 'unexpected child element majorTickMark'.\n                        InsertAxisChildInOrder(ax, new C.AxisPosition { Val = axPos });\n                    }\n                    break;\n                }\n\n                case \"crosses\":\n                {\n                    var plotArea2 = chart.GetFirstChild<C.PlotArea>();\n                    var valAx = plotArea2?.GetFirstChild<C.ValueAxis>();","sourceCodeStart":1870,"sourceCodeEnd":1906,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/Chart/ChartHelper.Setter.cs#L1870-L1906","documentation":"Thrown when 'axisPosition'/'axisPos' does not match any switch arm. OOXML ST_AxisPos is {t, b, l, r}; the setter also accepts long-form top/bottom/left/right. Anything else is rejected. The element is inserted in schema order (after delete) to avoid validator rejection.","triggerScenarios":"SetChartProperties with { [\"axisPos\"] = \"center\" }, \"middle\", or a misspelled token.","commonSituations":"'center' from a layout vocabulary that has no axis equivalent; case/whitespace mismatch; cross-mapping from labelPos tokens.","solutions":["Use top (t), bottom (b), left (l), or right (r).","Trim and ToLowerInvariant the value.","Whitelist against the four positions before calling Set."],"exampleFix":"// before\nSetChartProperties(part, new() { [\"axisPos\"] = \"center\" });\n// after\nSetChartProperties(part, new() { [\"axisPos\"] = \"bottom\" });","handlingStrategy":"validation","validationCode":"static readonly HashSet<string> AxisPos =\n    new[]{\"top\",\"t\",\"bottom\",\"b\",\"left\",\"l\",\"right\",\"r\"}, StringComparer.OrdinalIgnoreCase);\n\nstatic bool IsValidAxisPos(string v) =>\n    !string.IsNullOrWhiteSpace(v) && AxisPos.Contains(v.Trim().ToLowerInvariant());","typeGuard":"static bool IsKnownAxisPos(string v) =>\n    (v?.Trim().ToLowerInvariant()) is \"top\" or \"t\" or \"bottom\" or \"b\" or \"left\" or \"l\" or \"right\" or \"r\";","tryCatchPattern":"try { SetChartProperties(part, props); }\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"Invalid 'axisPos'\"))\n{ /* default to a chart-appropriate position and retry */ }","preventionTips":["Whitelist axisPos to top/bottom/left/right (and short forms).","Do not send 'center'/'middle' — axes have no such position.","Trim and lowercase free-text input."],"tags":["ooxml","chart","input-validation","axis","csharp"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}