{"record":{"id":"e381f992c3d122e7","repo":"spectreconsole/spectre.console","slug":"invalid-rgb-color-rgb","errorCode":null,"errorMessage":"Invalid RGB color '{rgb}'.","messagePattern":"Invalid RGB color '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Spectre.Console.Ansi/AnsiMarkupTagParser.cs","lineNumber":10,"sourceCode":"namespace Spectre.Console;\n\ninternal static class AnsiMarkupTagParser\n{\n    public static (Style Style, Link? Link) Parse(string text)\n    {\n        var result = Parse(text, out var error);\n        if (error != null)\n        {\n            throw new InvalidOperationException(error);\n        }\n\n        return result ?? throw new InvalidOperationException(\"Could not parse style.\");\n    }\n\n    public static bool TryParse(string text, [NotNullWhen(true)] out (Style Style, Link?)? result)\n    {\n        result = Parse(text, out _);\n        return result != null;\n    }\n\n    private static (Style Style, Link? Link)? Parse(string text, out string? error)\n    {\n        var effectiveDecoration = (Decoration?)null;\n        var effectiveForeground = (Color?)null;\n        var effectiveBackground = (Color?)null;\n        var effectiveLink = (string?)null;\n","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/spectreconsole/spectre.console/blob/0acc92fada6c42f13984e79c2b5f3d993bdfb099/src/Spectre.Console.Ansi/AnsiMarkupTagParser.cs#L1-L28","documentation":"ParseRgbColor finished without throwing but the shape was wrong: fewer than 3 characters after 'rgb', missing or mismatched parentheses, or not exactly 3 comma-separated parts. Reports 'Invalid RGB color {rgb}.'","triggerScenarios":"Malformed rgb syntax: `[rgb(1,2)]` (2 parts), `[rgb(1,2,3,4)]` (4 parts), `[rgb1,2,3]` (no parens), `[rgb]` (too short), or `[rgb(1 2 3)]` (space-separated).","commonSituations":"Missing parentheses; space vs comma confusion; extra trailing comma producing an empty part handled by StringSplitOptions.RemoveEmptyEntries changing the count.","solutions":["Use the exact form rgb(r,g,b) with parentheses and three comma-separated integers","Validate the string shape before embedding in markup","Prefer #rrggbb for programmatically generated colors to avoid formatting pitfalls"],"exampleFix":"// before\nAnsiMarkup.Parse(\"[rgb(1 2 3)]text[/]\");\n\n// after\nAnsiMarkup.Parse(\"[rgb(1,2,3)]text[/]\");","handlingStrategy":"validation","validationCode":"public static bool IsWellFormedRgb(string token) =>\n    Regex.IsMatch(token, @\"^rgb\\(\\d{1,3},\\d{1,3},\\d{1,3}\\)$\");","typeGuard":null,"tryCatchPattern":"try { AnsiMarkup.Parse(markup); }\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Invalid RGB color\"))\n{ /* rewrite using exactly rgb(r,g,b) */ }","preventionTips":["Use the exact rgb(r,g,b) shape: parentheses, three comma-separated ints","Don't mix commas and spaces inside rgb()","Validate the format string before embedding"],"tags":["markup","color","rgb","parsing","spectre-console"],"backgroundTag":null,"analyzedSha":"0acc92fada6c42f13984e79c2b5f3d993bdfb099","analyzedAt":"2026-08-13T18:27:21.983Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}