ppy/osu · error · InvalidOperationException
Color specified in incorrect format (should be R,G,B or R,G,
Error message
Color specified in incorrect format (should be R,G,B or R,G,B,A): {pair.Value} What it means
Thrown by LegacyDecoder.convertSettingStringToColor4 when a colour specification line doesn't split into exactly 3 or 4 comma-separated components. The expected format is 'R,G,B' or 'R,G,B,A'. Having fewer than 3 or more than 4 values triggers this before any parsing is attempted.
Source
Thrown at osu.Game/Beatmaps/Formats/LegacyDecoder.cs:109
case Section.Colours:
HandleColours(output, line, false);
return;
}
}
protected string StripComments(string line)
{
int index = line.AsSpan().IndexOf("//".AsSpan());
if (index > 0)
return line.Substring(0, index);
return line;
}
private Color4 convertSettingStringToColor4(string[] split, bool allowAlpha, KeyValuePair<string, string> pair)
{
if (split.Length != 3 && split.Length != 4)
throw new InvalidOperationException($@"Color specified in incorrect format (should be R,G,B or R,G,B,A): {pair.Value}");
Color4 colour;
try
{
byte alpha = allowAlpha && split.Length == 4 ? byte.Parse(split[3]) : (byte)255;
colour = new Color4(byte.Parse(split[0]), byte.Parse(split[1]), byte.Parse(split[2]), alpha);
}
catch
{
throw new InvalidOperationException(@"Color must be specified with 8-bit integer components");
}
return colour;
}
protected void HandleColours<TModel>(TModel output, string line, bool allowAlpha)
{
View on GitHub (pinned to d9c73e12ad)
Solutions
- Inspect the colour line shown in the error message and ensure it has exactly 3 (R,G,B) or 4 (R,G,B,A) integer values.
- Fix the .osu/.osb file's [Colours] section: e.g. change 'Combo1 : 255,0,0' (valid) instead of 'Combo1 : 255,0' (invalid).
- Re-export the beatmap/skin from a working editor if the file is extensively corrupted.
Example fix
// before (.osu [Colours] section): // Combo1 : 255,128 // after: // Combo1 : 255,128,0
Defensive patterns
Strategy: validation
Validate before calling
// Validate colour format before parsing
string[] split = pair.Value.Split(',');
if (split.Length != 3 && split.Length != 4)
throw new InvalidOperationException($"Invalid colour format: expected 3 or 4 components, got {split.Length}"); Try / catch
try
{
decoder.Decode(reader);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("incorrect format"))
{
Logger.Log($"Malformed colour line in beatmap: {ex.Message}", LoggingTarget.Database);
} Prevention
- If editing .osu files by hand, always use exactly 3 (R,G,B) or 4 (R,G,B,A) comma-separated values for colours.
- Validate colour strings programmatically before writing to .osu files.
- Use a beatmap editor that correctly formats colour values.
When it happens
Trigger: Decoding a .osu/.osb file where a colour line in [Colours] (or a ComboN colour) has the wrong number of comma-separated values — e.g. 'Combo1 : 255' (1 value), 'Combo1 : 255,0,0,0,0' (5 values), or an empty value field.
Common situations: Manual editing of a .osu file where a colour line is truncated or has extra values; a buggy skin/beatmap editor that writes malformed colour strings; a copy-paste error introducing extra commas.
Related errors
- Color must be specified with 8-bit integer components
- Beat length cannot be NaN in a timing control point
- Not a number
- Ruleset is not available locally.
- Unknown event type: {split[0]}
AI-assisted analysis of ppy/osu@d9c73e12ad (2026-08-13).
Data as JSON: /api/errors/5546240d74041135.
Report an issue: GitHub.