{"record":{"id":"6ab841c0787f4019","repo":"iOfficeAI/OfficeCLI","slug":"invalid-referenceline-value-parts-0-expected","errorCode":null,"errorMessage":"Invalid referenceLine value '{parts[0]}'. Expected: number or number:color:label:dash (e.g. '50:FF0000:Target:dash') or number:color:width:dash (e.g. '50:FF0000:2:dash').","messagePattern":"Invalid referenceLine value '(.+?)'\\. Expected: number or number:color:label:dash \\(e\\.g\\. '50:FF0000:Target:dash'\\) or number:color:width:dash \\(e\\.g\\. '50:FF0000:2:dash'\\)\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/Chart/ChartHelper.Advanced.cs","lineNumber":45,"sourceCode":"    /// e.g. \"50\", \"75:FF0000\", \"100:00AA00:Target\", \"80:0000FF:Average:dash\",\n    ///      \"50:FF0000:2.5:dash\", \"50:FF0000:2:dash:Target\", \"50:FF0000::dash:Target\"\n    /// </summary>\n    internal static void AddReferenceLine(C.Chart chart, string spec, bool removeExisting = true)\n    {\n        const double DefaultWidthPt = 1.5;\n        var plotArea = chart.GetFirstChild<C.PlotArea>();\n        if (plotArea == null) return;\n\n        // Caller may suppress the sweep when accumulating multiple lines from\n        // a semicolon-joined value (see Setter `case \"referenceline\"`).\n        if (removeExisting)\n            RemoveExistingReferenceLines(plotArea);\n\n        var parts = spec.Split(':');\n        if (!double.TryParse(parts[0].Trim(),\n            System.Globalization.NumberStyles.Float,\n            System.Globalization.CultureInfo.InvariantCulture, out var refValue))\n            throw new ArgumentException(\n                $\"Invalid referenceLine value '{parts[0]}'. Expected: number or number:color:label:dash (e.g. '50:FF0000:Target:dash') or number:color:width:dash (e.g. '50:FF0000:2:dash').\");\n\n        var color = parts.Length > 1 ? parts[1].Trim() : \"FF0000\";\n        double widthPt = DefaultWidthPt;\n        string label = $\"Ref ({refValue.ToString(\"G\", System.Globalization.CultureInfo.InvariantCulture)})\";\n        string dash = \"dash\";\n\n        // Positional parse — see doc comment above. parts[0..1] already consumed.\n        if (parts.Length == 3)\n        {\n            label = parts[2].Trim();\n        }\n        else if (parts.Length == 4)\n        {\n            var p2 = parts[2].Trim();\n            var p3 = parts[3].Trim();\n            // Disambiguate: \"50:FF0000:2.5:dash\" (width form) vs \"50:FF0000:Target:dash\" (legacy label form).\n            // Only treat p2 as width if it parses as a number AND p3 is a recognized dash keyword — both","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/Chart/ChartHelper.Advanced.cs#L27-L63","documentation":"A reference line spec is parsed positionally from a colon-delimited string (value:color:label:dash or value:color:width:dash). The first segment (parts[0]) must be a numeric value parseable as a double with InvariantCulture. If double.TryParse fails on the trimmed first segment, the library rejects the entire spec with the expected format examples.","triggerScenarios":"Passing a referenceLine value where the first colon-delimited segment is non-numeric: 'abc:red:Label:dash', ':FF0000', or 'N/A'. Called from the Setter case 'referenceline' or directly from the chart helper that splits the spec by ':'.","commonSituations":"Using locale-specific number formats with commas as decimal separators ('50,5:FF0000'). Passing a label as the first segment by mistake. Using an empty value. Using a formula reference instead of a literal number.","solutions":["Ensure the first segment is a plain number in invariant (dot-decimal) format: '50:FF0000:Target:dash'.","Use a dot as the decimal separator: '0.5' not '0,5'.","Check that no leading colon or label appears before the numeric value."],"exampleFix":"// before\nreferenceline: \"Target:FF0000:Label:dash\"\n// after\nreferenceline: \"50:FF0000:Target:dash\"\n// 50 is the value, FF0000 is the color","handlingStrategy":"validation","validationCode":"static bool TryParseReferenceLineValue(string spec, out double value)\n{\n    var parts = spec.Split(':');\n    return double.TryParse(parts[0].Trim(), System.Globalization.NumberStyles.Float,\n        System.Globalization.CultureInfo.InvariantCulture, out value);\n}","typeGuard":null,"tryCatchPattern":"try { ChartHelperAdvanced.AddReferenceLine(chart, spec); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Invalid referenceLine value\"))\n{\n    Console.Error.WriteLine($\"{ex.Message}\\nExpected format: number:color:label:dash\");\n}","preventionTips":["Always put the numeric value as the first colon-delimited segment.","Use invariant (dot-decimal) number format, not locale-specific commas.","Validate the first segment parses as a double before calling the chart helper."],"tags":["chart","reference-line","number-parsing","invalid-value"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}