{"record":{"id":"4d7967551255b6d7","repo":"iOfficeAI/OfficeCLI","slug":"unknown-databar-axisposition-dbaxispos-valid","errorCode":null,"errorMessage":"Unknown dataBar axisPosition '{dbAxisPos}'. Valid: automatic, middle, none.","messagePattern":"Unknown dataBar axisPosition '(.+?)'\\. Valid: automatic, middle, none\\.","errorType":"validation","errorClass":"System.ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Add.Cf.cs","lineNumber":208,"sourceCode":"        var cf = new ConditionalFormatting(cfRule)\n        {\n            SequenceOfReferences = new ListValue<StringValue>(\n                sqref.Split(' ').Select(s => new StringValue(s)))\n        };\n\n        var wsElement = GetSheet(cfWorksheet);\n        InsertConditionalFormatting(wsElement, cf);\n\n        // R10-1: Build the x14:dataBar counterpart under worksheet extLst.\n        var dbNegColor = ParseHelpers.NormalizeArgbColor(properties.GetValueOrDefault(\"negativeColor\", \"FF0000\"));\n        var dbAxisColor = ParseHelpers.NormalizeArgbColor(properties.GetValueOrDefault(\"axisColor\", \"000000\"));\n        var dbAxisPos = (properties.GetValueOrDefault(\"axisPosition\") ?? \"automatic\").ToLowerInvariant();\n        var dbAxisPosVal = dbAxisPos switch\n        {\n            \"middle\" => X14.DataBarAxisPositionValues.Middle,\n            \"none\" => X14.DataBarAxisPositionValues.None,\n            \"automatic\" or \"auto\" => X14.DataBarAxisPositionValues.Automatic,\n            _ => throw new ArgumentException(\n                $\"Unknown dataBar axisPosition '{dbAxisPos}'. Valid: automatic, middle, none.\")\n        };\n\n        // CF6 — accept user-supplied bar length bounds (defaults follow Excel's\n        // 0/100 percentage convention) and bar direction (leftToRight/rightToLeft).\n        var dbMinLength = 0U;\n        if (properties.TryGetValue(\"minLength\", out var dbMinLenStr)\n            && uint.TryParse(dbMinLenStr, out var dbMinLenParsed))\n            dbMinLength = dbMinLenParsed;\n        var dbMaxLength = 100U;\n        if (properties.TryGetValue(\"maxLength\", out var dbMaxLenStr)\n            && uint.TryParse(dbMaxLenStr, out var dbMaxLenParsed))\n            dbMaxLength = dbMaxLenParsed;\n\n        var x14DataBar = new X14.DataBar\n        {\n            MinLength = dbMinLength,\n            MaxLength = dbMaxLength,","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Add.Cf.cs#L190-L226","documentation":"Thrown by AddDataBar when building the x14:dataBar extension (Excel 2010+ bar) for a dataBar conditional format. The 'axisPosition' property controls where the axis line is drawn relative to the bar; it is lowercased and matched against a fixed allowlist. An unrecognized value is rejected rather than silently coerced, because emitting an unknown X14.DataBarAxisPositionValues enum would produce a file real Excel refuses to open.","triggerScenarios":"Calling Add with type=databar (or the cf alias with type=databar) and passing axisPosition=<value> where value is not one of: 'middle', 'none', 'automatic', 'auto' (case-insensitive). The default when the property is omitted is 'automatic'.","commonSituations":"Typo such as axisPosition=center (the Excel UI label) instead of 'middle'; passing axisPosition=left/right which are not valid axis positions (those are bar *direction* values); copying the OOXML attribute spelling 'mid' from a raw XML sample.","solutions":["Set axisPosition to one of: automatic (default), middle, or none. The alias 'auto' is also accepted.","If you meant to control bar fill direction (left vs right), use the 'direction' property (leftToRight/rightToLeft/context), not axisPosition.","Omit axisPosition entirely to accept the 'automatic' default."],"exampleFix":"// before: axisPosition=center\nadd /Sheet1/A1:A10 cf type=databar axisPosition=center\n// after: axisPosition=middle\nadd /Sheet1/A1:A10 cf type=databar axisPosition=middle","handlingStrategy":"validation","validationCode":"var valid = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { \"automatic\", \"auto\", \"middle\", \"none\" };\nvar pos = properties.GetValueOrDefault(\"axisPosition\") ?? \"automatic\";\nif (!valid.Contains(pos))\n    throw new ArgumentException($\"axisPosition '{pos}' invalid; choose from {string.Join(\", \", valid)}.\");","typeGuard":"static readonly HashSet<string> DataBarAxisPositions = new(StringComparer.OrdinalIgnoreCase)\n{ \"automatic\", \"auto\", \"middle\", \"none\" };\nstatic bool IsValidAxisPosition(string? s) => s is null || DataBarAxisPositions.Contains(s);","tryCatchPattern":"try { return Add(path, \"databar\", pos, props); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"axisPosition\"))\n{ props[\"axisPosition\"] = \"automatic\"; return Add(path, \"databar\", pos, props); }","preventionTips":["Whitelist axisPosition against automatic/middle/none before calling Add.","Remember 'auto' is the only shorthand alias; other short forms are rejected.","Do not confuse axisPosition (axis line placement) with direction (bar fill direction)."],"tags":["excel","conditional-formatting","databar","enum-validation","argument-validation"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}