{"record":{"id":"124de158ba592ed5","repo":"iOfficeAI/OfficeCLI","slug":"invalid-horizontal-alignment-value-valid-val","errorCode":null,"errorMessage":"Invalid horizontal alignment: '{value}'. Valid values: left, center, right, justify.","messagePattern":"Invalid horizontal alignment: '(.+?)'\\. Valid values: left, center, right, justify\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/ExcelStyleManager.cs","lineNumber":1811,"sourceCode":"\n    private static bool IsTruthy(string? value) =>\n        ParseHelpers.IsTruthy(value);\n\n    private static bool IsValidBooleanString(string? value) =>\n        ParseHelpers.IsValidBooleanString(value);\n\n    private static HorizontalAlignmentValues ParseHAlign(string value) =>\n        value.ToLowerInvariant() switch\n        {\n            \"left\" => HorizontalAlignmentValues.Left,\n            \"center\" => HorizontalAlignmentValues.Center,\n            \"right\" => HorizontalAlignmentValues.Right,\n            \"justify\" => HorizontalAlignmentValues.Justify,\n            \"general\" => HorizontalAlignmentValues.General,\n            \"fill\" => HorizontalAlignmentValues.Fill,\n            \"centeracrossselection\" or \"centercontinuous\" => HorizontalAlignmentValues.CenterContinuous,\n            \"distributed\" => HorizontalAlignmentValues.Distributed,\n            _ => throw new ArgumentException($\"Invalid horizontal alignment: '{value}'. Valid values: left, center, right, justify.\")\n        };\n\n    private static VerticalAlignmentValues ParseVAlign(string value) =>\n        value.ToLowerInvariant() switch\n        {\n            \"top\" => VerticalAlignmentValues.Top,\n            \"center\" => VerticalAlignmentValues.Center,\n            \"bottom\" => VerticalAlignmentValues.Bottom,\n            \"justify\" => VerticalAlignmentValues.Justify,\n            \"distributed\" => VerticalAlignmentValues.Distributed,\n            _ => throw new ArgumentException($\"Invalid vertical alignment: '{value}'. Valid values: top, center, bottom.\")\n        };\n}\n","sourceCodeStart":1793,"sourceCodeEnd":1825,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/ExcelStyleManager.cs#L1793-L1825","documentation":"Thrown by the Excel horizontal-alignment parser when a value does not match a known token. Note the error message lists only 'left, center, right, justify' as valid, but the switch also accepts general, fill, centeracrossselection/centercontinuous, and distributed — so the message is narrower than the actual accepted set.","triggerScenarios":"Passing alignment/horizontal= with a value outside the switch arms. The default arm throws listing only the four most common values, which can be misleading since the parser actually accepts more.","commonSituations":"Typo such as 'centre' (British) or 'left '; a value the app thinks is valid but the parser's listed options don't include (e.g. 'distributed'); whitespace not trimmed.","solutions":["Use one of the actually-supported values: left, center, right, justify, general, fill, centeracrossselection (or centercontinuous), distributed.","Trim and lowercase the input before passing.","If you hit this with a value the message says is invalid but you expect to work, try the extended set (general/fill/distributed/centeracrossselection)."],"exampleFix":"// before\nalign[\"horizontal\"] = \"centre\"; // British spelling not accepted\n// after\nalign[\"horizontal\"] = \"center\";","handlingStrategy":"type-guard","validationCode":"static readonly HashSet<string> ValidHAlign = new(StringComparer.OrdinalIgnoreCase)\n{ \"left\",\"center\",\"right\",\"justify\",\"general\",\"fill\",\"centeracrossselection\",\"centercontinuous\",\"distributed\" };\nstatic string NormalizeHAlign(string v) => ValidHAlign.Contains(v?.Trim() ?? \"\") ? v.Trim().ToLowerInvariant() : throw new ArgumentException(\"invalid halign\");","typeGuard":"static bool IsValidHAlign(string v) => ValidHAlign.Contains(v?.Trim() ?? \"\");","tryCatchPattern":"try { SetAlign(horizontal: value); }\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"Invalid horizontal alignment\"))\n{ /* fallback to 'general' */ }","preventionTips":["Trim/lowercase alignment values.","Map British spellings (centre) to center upstream."],"tags":["excel","alignment","validation","error-message-mismatch"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}