{"record":{"id":"9fddd18775f2b56c","repo":"iOfficeAI/OfficeCLI","slug":"invalid-colorrule-spec-expected-threshold-be","errorCode":null,"errorMessage":"Invalid colorRule '{spec}'. Expected: threshold:belowColor:aboveColor (e.g. '0:FF0000:00AA00') or low:lowColor:mid:midColor:high:highColor (e.g. '0:FF0000:50:FFAA00:100:00AA00').","messagePattern":"Invalid colorRule '(.+?)'\\. Expected: threshold:belowColor:aboveColor \\(e\\.g\\. '0:FF0000:00AA00'\\) or low:lowColor:mid:midColor:high:highColor \\(e\\.g\\. '0:FF0000:50:FFAA00:100:00AA00'\\)\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/Chart/ChartHelper.Advanced.cs","lineNumber":299,"sourceCode":"                or \"longdashdot\" or \"lgdashdot\"\n                or \"longdashdotdot\" or \"lgdashdotdot\" => true,\n            _ => false\n        };\n    }\n\n    // ==================== Conditional Coloring ====================\n\n    /// <summary>\n    /// Apply conditional coloring to data points based on value thresholds.\n    /// Format: \"threshold:belowColor:aboveColor\" or \"low:lowColor:mid:midColor:high:highColor\"\n    /// Simple: \"0:FF0000:00AA00\" — below 0 = red, above 0 = green\n    /// Three-tier: \"0:FF0000:50:FFAA00:100:00AA00\" — red/orange/green zones\n    /// </summary>\n    internal static void ApplyColorRule(C.PlotArea plotArea, string spec)\n    {\n        var parts = spec.Split(':');\n        if (parts.Length < 3)\n            throw new ArgumentException(\n                $\"Invalid colorRule '{spec}'. Expected: threshold:belowColor:aboveColor (e.g. '0:FF0000:00AA00') \" +\n                \"or low:lowColor:mid:midColor:high:highColor (e.g. '0:FF0000:50:FFAA00:100:00AA00').\");\n\n        var rules = new List<(double threshold, string color)>();\n        string topColor;\n\n        if (parts.Length == 3)\n        {\n            // Simple two-zone: threshold:belowColor:aboveColor\n            if (!double.TryParse(parts[0], System.Globalization.NumberStyles.Float,\n                System.Globalization.CultureInfo.InvariantCulture, out var t))\n                throw new ArgumentException($\"Invalid threshold '{parts[0]}' in colorRule. Expected a number.\");\n            rules.Add((t, parts[1].Trim()));\n            topColor = parts[2].Trim();\n        }\n        else\n        {\n            // Multi-zone: t1:c1:t2:c2:...:cN","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/Chart/ChartHelper.Advanced.cs#L281-L317","documentation":"The conditional coloring rule (colorRule) applies threshold-based coloring to chart data points. The spec is colon-delimited: either a simple 3-part form (threshold:belowColor:aboveColor) or a multi-zone form (t1:c1:t2:c2:...:cN). If the spec has fewer than 3 parts, the library rejects it immediately with the expected format. The minimum 3 parts ensures at least one threshold, one below-color, and one above-color.","triggerScenarios":"Passing a colorRule spec with fewer than 3 colon-separated segments: 'FF0000' (1 part), '0:FF0000' (2 parts), or an empty string. Called from ApplyColorRule which is invoked by the Setter case 'colorrule'.","commonSituations":"Forgetting the above-threshold color. Passing a single hex color instead of a threshold:color:color triple. Using a different delimiter (comma, semicolon) instead of colon. Copying a partial spec from documentation.","solutions":["Provide at least 3 parts: threshold:belowColor:aboveColor, e.g. '0:FF0000:00AA00'.","For multi-zone coloring, provide alternating threshold:color pairs with an optional trailing top color.","Ensure you use ':' as the delimiter, not ',' or ';'."],"exampleFix":"// before\ncolorrule: \"FF0000:00AA00\"\n// after\ncolorrule: \"0:FF0000:00AA00\"\n// three-zone\ncolorrule: \"0:FF0000:50:FFAA00:100:00AA00\"","handlingStrategy":"validation","validationCode":"static bool IsValidColorRuleSpec(string spec)\n{\n    var parts = spec.Split(':');\n    return parts.Length >= 3;\n}","typeGuard":null,"tryCatchPattern":"try { ChartHelperAdvanced.ApplyColorRule(plotArea, spec); }\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"Invalid colorRule\"))\n{\n    Console.Error.WriteLine($\"{ex.Message}\\nExpected: threshold:belowColor:aboveColor or multi-zone.\");\n}","preventionTips":["Always provide at least 3 segments: threshold:belowColor:aboveColor.","Use ':' as the delimiter consistently.","Validate segment count before calling ApplyColorRule."],"tags":["chart","conditional-coloring","colorrule","invalid-format"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}