{"record":{"id":"9a1a8033e3884a05","repo":"iOfficeAI/OfficeCLI","slug":"unknown-align-value-shpalign-valid-left-cen","errorCode":null,"errorMessage":"Unknown align value '{shpAlign}'. Valid: left, center, right, justify.","messagePattern":"Unknown align value '(.+?)'\\. Valid: left, center, right, justify\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Add.Drawings.cs","lineNumber":875,"sourceCode":"            // Fonts last (schema order). Accept `font=Arial` or `font.name=Arial`.\n            string? rawFontName = properties.GetValueOrDefault(\"font.name\")\n                ?? properties.GetValueOrDefault(\"font\");\n            if (rawFontName != null)\n            {\n                rPr.AppendChild(new Drawing.LatinFont { Typeface = rawFontName });\n                rPr.AppendChild(new Drawing.EastAsianFont { Typeface = rawFontName });\n            }\n\n            var pPr = new Drawing.ParagraphProperties();\n            if (properties.TryGetValue(\"align\", out var shpAlign))\n            {\n                pPr.Alignment = shpAlign.ToLowerInvariant() switch\n                {\n                    \"center\" or \"c\" or \"ctr\" => Drawing.TextAlignmentTypeValues.Center,\n                    \"right\" or \"r\" => Drawing.TextAlignmentTypeValues.Right,\n                    \"left\" or \"l\" => Drawing.TextAlignmentTypeValues.Left,\n                    \"justify\" or \"just\" => Drawing.TextAlignmentTypeValues.Justified,\n                    _ => throw new ArgumentException(\n                        $\"Unknown align value '{shpAlign}'. Valid: left, center, right, justify.\")\n                };\n            }\n\n            txBody.AppendChild(new Drawing.Paragraph(\n                pPr,\n                new Drawing.Run(rPr, new Drawing.Text(line))\n            ));\n        }\n\n        var shape = new XDR.Shape(\n            new XDR.NonVisualShapeProperties(\n                new XDR.NonVisualDrawingProperties { Id = shpId, Name = shpName },\n                new XDR.NonVisualShapeDrawingProperties()\n            ),\n            spPr,\n            txBody\n        );","sourceCodeStart":857,"sourceCodeEnd":893,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Add.Drawings.cs#L857-L893","documentation":"Thrown when a shape paragraph's `align=` property does not match a recognized horizontal-alignment token. The switch accepts left, center, right, justify (aliases l, c/ctr, r, just). Any other token — e.g. `align=justify-all`, `align=distributed`, `align=start` — hits the default arm and throws. This is the paragraph-level (not run-level) alignment on the TextBody paragraph.","triggerScenarios":"Passing `--prop align=distributed` or `--prop align=start` (CSS/HTML vocabulary) or `align=center-justify`. The switch is case-insensitive via ToLowerInvariant but does not accept XML enum spellings like `center` vs `ctr` beyond the listed aliases.","commonSituations":"Mapping from CSS (`text-align: justify`) but using a non-listed variant like `justify-all`; using OOXML enum string `distributed` which isn't exposed on this Add path.","solutions":["Use left, center, right, or justify (aliases l, c/ctr, r, just).","Omit `align=` to inherit the paragraph default."],"exampleFix":"// before\nadd ./book.xlsx /Sheet1 shape --type textbox --prop font.text=Hi --prop align=start\n// after\nadd ./book.xlsx /Sheet1 shape --type textbox --prop font.text=Hi --prop align=left","handlingStrategy":"type-guard","validationCode":"var validAlign = new[]{\"left\",\"l\",\"center\",\"c\",\"ctr\",\"right\",\"r\",\"justify\",\"just\"};\nif (!validAlign.Contains((align ?? \"\").ToLowerInvariant()))\n    throw new InvalidOperationException($\"Invalid align '{align}'\");","typeGuard":"static readonly HashSet<string> AlignTokens = new(StringComparer.OrdinalIgnoreCase)\n    {\"left\",\"l\",\"center\",\"c\",\"ctr\",\"right\",\"r\",\"justify\",\"just\"};\nstatic bool IsValidAlign(string? v) => v is not null && AlignTokens.Contains(v);","tryCatchPattern":"try { handler.Add(...); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Unknown align\"))\n{ /* reprompt with the four canonical values */ }","preventionTips":["Use only left/center/right/justify for paragraph alignment.","Do not confuse this paragraph-level align with the run-level valign (error 542)."],"tags":["excel","shape","align","enum-value","input-validation"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}