{"record":{"id":"fb6084cb4b347a81","repo":"ppy/osu","slug":"can-t-have-zero-or-fewer-stages","errorCode":null,"errorMessage":"Can't have zero or fewer stages.","messagePattern":"Can't have zero or fewer stages\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs","lineNumber":61,"sourceCode":"        }\r\n\r\n        public override bool ReceivePositionalInputAt(Vector2 screenSpacePos)\r\n        {\r\n            foreach (var s in stages)\r\n            {\r\n                if (s.ReceivePositionalInputAt(screenSpacePos))\r\n                    return true;\r\n            }\r\n\r\n            return false;\r\n        }\r\n\r\n        public ManiaPlayfield(List<StageDefinition> stageDefinitions)\r\n        {\r\n            ArgumentNullException.ThrowIfNull(stageDefinitions);\r\n\r\n            if (stageDefinitions.Count <= 0)\r\n                throw new ArgumentException(\"Can't have zero or fewer stages.\");\r\n\r\n            GridContainer playfieldGrid;\r\n            AddInternal(playfieldGrid = new GridContainer\r\n            {\r\n                RelativeSizeAxes = Axes.Both,\r\n                Content = new[] { new Drawable[stageDefinitions.Count] }\r\n            });\r\n\r\n            var columnAction = ManiaAction.Key1;\r\n            int firstColumnIndex = 0;\r\n\r\n            for (int i = 0; i < stageDefinitions.Count; i++)\r\n            {\r\n                var newStage = CreateStage(firstColumnIndex, stageDefinitions[i], ref columnAction);\r\n\r\n                playfieldGrid.Content[0][i] = newStage;\r\n\r\n                stages.Add(newStage);\r","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/ppy/osu/blob/d9c73e12adff2feaae4a3e158d36fe5883faf6ca/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs#L43-L79","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nvar stages = new List<StageDefinition>(); // accidentally empty\nplayfield = new ManiaPlayfield(stages);\n\n// after\nvar stages = new List<StageDefinition>\n{\n    new StageDefinition { Columns = 4 }\n};\nif (stages.Count == 0)\n    throw new InvalidOperationException(\"At least one stage is required.\");\nplayfield = new ManiaPlayfield(stages);","handlingStrategy":"validation","validationCode":"// Ensure stage definitions are non-empty before constructing the playfield\nif (stageDefinitions == null || stageDefinitions.Count == 0)\n    throw new InvalidOperationException(\"Cannot create ManiaPlayfield without at least one stage.\");\nvar playfield = new ManiaPlayfield(stageDefinitions);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["mania-ruleset","playfield","validation","gameplay"],"backgroundTag":null,"analyzedSha":"d9c73e12adff2feaae4a3e158d36fe5883faf6ca","analyzedAt":"2026-08-13T14:12:54.015Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}