ppy/osu · error · ArgumentException
Can't have zero or fewer stages.
Error message
Can't have zero or fewer stages.
What it means
ManiaPlayfield's constructor requires at least one StageDefinition to build the playfield grid (it allocates a Drawable[stageDefinitions.Count] array for the GridContainer content). An empty list produces a zero-column playfield, which is structurally invalid. ArgumentNullException.ThrowIfNull handles null; this ArgumentException handles the zero-or-negative count.
Source
Thrown at osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs:61
}
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos)
{
foreach (var s in stages)
{
if (s.ReceivePositionalInputAt(screenSpacePos))
return true;
}
return false;
}
public ManiaPlayfield(List<StageDefinition> stageDefinitions)
{
ArgumentNullException.ThrowIfNull(stageDefinitions);
if (stageDefinitions.Count <= 0)
throw new ArgumentException("Can't have zero or fewer stages.");
GridContainer playfieldGrid;
AddInternal(playfieldGrid = new GridContainer
{
RelativeSizeAxes = Axes.Both,
Content = new[] { new Drawable[stageDefinitions.Count] }
});
var columnAction = ManiaAction.Key1;
int firstColumnIndex = 0;
for (int i = 0; i < stageDefinitions.Count; i++)
{
var newStage = CreateStage(firstColumnIndex, stageDefinitions[i], ref columnAction);
playfieldGrid.Content[0][i] = newStage;
stages.Add(newStage);
View on GitHub (pinned to d9c73e12ad)
Solutions
- Ensure the stageDefinitions list passed to ManiaPlayfield contains at least one StageDefinition.
- Validate the key count or stage count upstream before creating the playfield.
- Check any mod (e.g., ManiaKeyMod) or configuration that determines the number of stages and confirm it cannot resolve to zero.
Example fix
// before
var stages = new List<StageDefinition>(); // accidentally empty
playfield = new ManiaPlayfield(stages);
// after
var stages = new List<StageDefinition>
{
new StageDefinition { Columns = 4 }
};
if (stages.Count == 0)
throw new InvalidOperationException("At least one stage is required.");
playfield = new ManiaPlayfield(stages); Defensive patterns
Strategy: validation
Validate before calling
// Ensure stage definitions are non-empty before constructing the playfield
if (stageDefinitions == null || stageDefinitions.Count == 0)
throw new InvalidOperationException("Cannot create ManiaPlayfield without at least one stage.");
var playfield = new ManiaPlayfield(stageDefinitions); Prevention
- Validate stage/key counts at the ruleset configuration level before playfield construction.
- Add unit tests that exercise edge cases like zero-key configurations.
- Check the output of any mod that transforms key counts for empty results.
When it happens
Trigger: Constructing new ManiaPlayfield(new List<StageDefinition>()) or new ManiaPlayfield(stageDefinitions) where stageDefinitions.Count is 0. This can arise from a key-binding or ruleset configuration that resolves to zero keys/stages.
Common situations: A Mania mod or key-count converter that produces an empty stage definition list; misconfigured key bindings that resolve to zero keys; custom ruleset integration that dynamically builds stages but hits an edge case producing none.
Related errors
- Beatmap can not be converted for the ruleset (ruleset: {rule
- Provided client ID must be an integer.
- HitObjectContainer should be set before CheckHittable is cal
- HitObjectContainer should be set before CheckHittable is cal
- HitObjectContainer should be set before HandleHit is called.
AI-assisted analysis of ppy/osu@d9c73e12ad (2026-08-13).
Data as JSON: /api/errors/fb6084cb4b347a81.
Report an issue: GitHub.