{"record":{"id":"96be49f557b495ec","repo":"iOfficeAI/OfficeCLI","slug":"unknown-cf-type-cftyperaw-valid-databar-ico","errorCode":null,"errorMessage":"Unknown CF type '{cfTypeRaw}'. Valid: databar, iconset, colorscale, formula, cellIs, top10, topPercent, bottom, bottomPercent, aboveAverage, belowAverage, uniqueValues, duplicateValues, containsText, notContains, beginsWith, endsWith, containsBlanks, notContainsBlanks, containsErrors, notContainsErrors, dateOccurring.","messagePattern":"Unknown CF type '(.+?)'\\. Valid: databar, iconset, colorscale, formula, cellIs, top10, topPercent, bottom, bottomPercent, aboveAverage, belowAverage, uniqueValues, duplicateValues, containsText, notContains, beginsWith, endsWith, containsBlanks, notContainsBlanks, containsErrors, notContainsErrors, dateOccurring\\.","errorType":"validation","errorClass":"System.ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Add.Cf.cs","lineNumber":64,"sourceCode":"            // user-facing aliases for the OOXML `top10` cfRule. Without this\n            // mapping, the dispatch fell through to the default `databar`\n            // branch and silently rewrote the rule type. Set `percent`/\n            // `bottom` properties so the topn branch emits the right attrs.\n            \"topn\" or \"top10\" or \"top\" => Add(parentPath, \"topn\", position, properties),\n            \"toppercent\" => AddTopRouted(parentPath, position, properties, percent: true, bottom: false),\n            \"bottom\" => AddTopRouted(parentPath, position, properties, percent: false, bottom: true),\n            \"bottompercent\" => AddTopRouted(parentPath, position, properties, percent: true, bottom: true),\n            \"aboveaverage\" => Add(parentPath, \"aboveaverage\", position, properties),\n            \"uniquevalues\" => Add(parentPath, \"uniquevalues\", position, properties),\n            \"duplicatevalues\" => Add(parentPath, \"duplicatevalues\", position, properties),\n            \"containstext\" => Add(parentPath, \"containstext\", position, properties),\n            \"dateoccurring\" or \"timeperiod\" => Add(parentPath, \"dateoccurring\", position, properties),\n            \"belowaverage\" or \"containsblanks\" or \"notcontainsblanks\" or \"containserrors\" or \"notcontainserrors\" or \"contains\" or \"notcontains\" or \"beginswith\" or \"endswith\"\n                => Add(parentPath, \"cfextended\", position, properties),\n            // Reject unknown CF types instead of silently falling back to\n            // dataBar — silent fallback hides typos like `type=badtype` and\n            // produces a rule the user did not ask for.\n            _ => throw new ArgumentException(\n                $\"Unknown CF type '{cfTypeRaw}'. Valid: databar, iconset, colorscale, formula, cellIs, \"\n                + \"top10, topPercent, bottom, bottomPercent, aboveAverage, belowAverage, \"\n                + \"uniqueValues, duplicateValues, containsText, notContains, beginsWith, endsWith, \"\n                + \"containsBlanks, notContainsBlanks, containsErrors, notContainsErrors, dateOccurring.\")\n        };\n    }\n\n    // R39-1: thread `percent`/`bottom` flags into the topn branch so that\n    // `type=topPercent` / `type=bottom` / `type=bottomPercent` route to the\n    // same `top10` cfRule with the right attributes set, instead of falling\n    // through to the dataBar default. Mutates `properties` in place; keys\n    // already supplied by the user take precedence.\n    private string AddTopRouted(string parentPath, InsertPosition? position, Dictionary<string, string> properties, bool percent, bool bottom)\n    {\n        if (!properties.ContainsKey(\"percent\")) properties[\"percent\"] = percent ? \"true\" : \"false\";\n        if (!properties.ContainsKey(\"bottom\")) properties[\"bottom\"] = bottom ? \"true\" : \"false\";\n        return Add(parentPath, \"topn\", position, properties);\n    }","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Add.Cf.cs#L46-L82","documentation":"Thrown by AddCf (the cf alias dispatcher) when the type or rule property does not match any known conditional-formatting type. The switch has no silent default: an unrecognized value throws instead of falling back to dataBar, so typos surface immediately. The error message lists the full allowlist of valid type names.","triggerScenarios":"Add type=cf with properties[\"type\"]=\"badtype\", or rule=\"databars\" (plural typo), or any value not in the allowlist (databar, iconset, colorscale, formula, expression, cellIs, highlight, topn, top10, top, topPercent, bottom, bottomPercent, aboveAverage, belowAverage, uniqueValues, duplicateValues, containsText, dateOccurring, timePeriod, containsBlanks, notContainsBlanks, containsErrors, notContainsErrors, contains, notContains, beginsWith, endsWith). The comparison is case-insensitive.","commonSituations":"Typo in the type name (e.g. databars, colorScale vs colorscale). Using an Excel UI label that is not in the allowlist. Copying a type from documentation for a different library version. Note highlight requires an operator property to route to cellIs; without it, highlight is not matched and falls to the default throw.","solutions":["Correct the type/rule value to one from the allowlist in the error message.","If omitted, type defaults to databar for the cf alias; remove the type property to get a data bar.","For highlight, also supply operator= so it routes to cellIs."],"exampleFix":"// before\nprops[\"type\"] = \"databars\"; // typo\nhandler.Add(\"/Sheet1\", \"cf\", null, props);\n\n// after\nprops[\"type\"] = \"databar\";\nhandler.Add(\"/Sheet1\", \"cf\", null, props);","handlingStrategy":"validation","validationCode":"static readonly HashSet<string> CfTypes = new(StringComparer.OrdinalIgnoreCase)\n{ \"databar\",\"iconset\",\"colorscale\",\"formula\",\"expression\",\"cellis\",\"highlight\",\"topn\",\"top10\",\"top\",\"toppercent\",\"bottom\",\"bottompercent\",\"aboveaverage\",\"belowaverage\",\"uniquevalues\",\"duplicatevalues\",\"containstext\",\"dateoccurring\",\"timeperiod\",\"containsblanks\",\"notcontainsblanks\",\"containserrors\",\"notcontainserrors\",\"contains\",\"notcontains\",\"beginswith\",\"endswith\" };\nvar t = props.GetValueOrDefault(\"type\") ?? props.GetValueOrDefault(\"rule\");\nif (t != null && !CfTypes.Contains(t))\n    throw new ArgumentOutOfRangeException(\"type\", $\"Unknown CF type: {t}\");\nhandler.Add(\"/Sheet1\", \"cf\", null, props);","typeGuard":"static bool IsKnownCfType(string? t) => t == null || CfTypes.Contains(t);","tryCatchPattern":null,"preventionTips":["Keep a shared allowlist constant and validate type/rule against it before Add.","Omit the type property to accept the databar default for the cf alias.","Remember highlight also needs operator= to route to cellIs."],"tags":["excel","ooxml","conditional-formatting","cf","unknown-type","allowlist","argument"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}