{"record":{"id":"03a12dc0d2f6cebd","repo":"iOfficeAI/OfficeCLI","slug":"unknown-databar-direction-dbdir-valid-leftto","errorCode":null,"errorMessage":"Unknown dataBar direction '{dbDir}'. Valid: leftToRight, rightToLeft, context.","messagePattern":"Unknown dataBar direction '(.+?)'\\. Valid: leftToRight, rightToLeft, context\\.","errorType":"validation","errorClass":"System.ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Add.Cf.cs","lineNumber":237,"sourceCode":"        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,\n            AxisPosition = dbAxisPosVal\n        };\n        if (properties.TryGetValue(\"direction\", out var dbDir))\n        {\n            var dirNorm = SchemaKeyNormalizer.Normalize(dbDir);\n            x14DataBar.Direction = dirNorm switch\n            {\n                \"lefttoright\" or \"ltr\" => X14.DataBarDirectionValues.LeftToRight,\n                \"righttoleft\" or \"rtl\" => X14.DataBarDirectionValues.RightToLeft,\n                \"context\" => X14.DataBarDirectionValues.Context,\n                _ => throw new ArgumentException(\n                    $\"Unknown dataBar direction '{dbDir}'. Valid: leftToRight, rightToLeft, context.\")\n            };\n        }\n        var x14MinCfvo = new X14.ConditionalFormattingValueObject\n        {\n            Type = minVal != null\n                ? X14.ConditionalFormattingValueObjectTypeValues.Numeric\n                : X14.ConditionalFormattingValueObjectTypeValues.AutoMin\n        };\n        if (minVal != null) x14MinCfvo.Append(new DocumentFormat.OpenXml.Office.Excel.Formula(minVal));\n        x14DataBar.Append(x14MinCfvo);\n        var x14MaxCfvo = new X14.ConditionalFormattingValueObject\n        {\n            Type = maxVal != null\n                ? X14.ConditionalFormattingValueObjectTypeValues.Numeric\n                : X14.ConditionalFormattingValueObjectTypeValues.AutoMax\n        };\n        if (maxVal != null) x14MaxCfvo.Append(new DocumentFormat.OpenXml.Office.Excel.Formula(maxVal));","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Add.Cf.cs#L219-L255","documentation":"Thrown by AddDataBar when the optional 'direction' property is supplied on a dataBar conditional format. Direction sets whether bars grow left-to-right, right-to-left, or per-RTL context of the cell. The raw value is run through SchemaKeyNormalizer.Normalize (strips punctuation/casing) before matching, so the comparison keys are the normalized forms 'lefttoright', 'righttoleft', 'context'. An unknown value is rejected because the X14.DataBarDirectionValues enum has only those three members.","triggerScenarios":"Calling Add with type=databar and a direction= property whose normalized form is not lefttoright/ltr, righttoleft/rtl, or context. Example: direction=horizontal or direction=normal.","commonSituations":"Passing a UI-oriented label like 'horizontal' or 'forward'; confusing direction with axisPosition; passing direction=rtl expecting it to mean right-to-left when SchemaKeyNormalizer maps it correctly (so the real cause is usually a different string like direction=reverse).","solutions":["Set direction to leftToRight (alias ltr), rightToLeft (alias rtl), or context.","Omit the direction property if you want Excel's default (context)."],"exampleFix":"// before: direction=reverse\nadd /Sheet1/A1:A10 cf type=databar direction=reverse\n// after: direction=rightToLeft\nadd /Sheet1/A1:A10 cf type=databar direction=rightToLeft","handlingStrategy":"validation","validationCode":"var valid = new HashSet<string>(StringComparer.OrdinalIgnoreCase)\n{ \"leftToRight\", \"ltr\", \"rightToLeft\", \"rtl\", \"context\" };\nif (properties.TryGetValue(\"direction\", out var d) && !valid.Contains(d))\n    throw new ArgumentException($\"direction '{d}' invalid.\");","typeGuard":"static readonly HashSet<string> DataBarDirections = new(StringComparer.OrdinalIgnoreCase)\n{ \"leftToRight\", \"ltr\", \"rightToLeft\", \"rtl\", \"context\" };\nstatic bool IsValidDataBarDirection(string? s) => s is null || DataBarDirections.Contains(s);","tryCatchPattern":"try { return Add(path, \"databar\", pos, props); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"dataBar direction\"))\n{ props.Remove(\"direction\"); return Add(path, \"databar\", pos, props); }","preventionTips":["Validate direction against leftToRight/rightToLeft/context (or aliases ltr/rtl) first.","Omit direction to accept Excel's context default.","SchemaKeyNormalizer strips punctuation, but spelling must still match the normalized token."],"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"}