{"record":{"id":"d8ee598e4502bddd","repo":"spectreconsole/spectre.console","slug":"the-number-of-row-columns-are-greater-than-the-num","errorCode":null,"errorMessage":"The number of row columns are greater than the number of grid columns.","messagePattern":"The number of row columns are greater than the number of grid columns\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Spectre.Console/Widgets/Grid.cs","lineNumber":89,"sourceCode":"        _padRightCell = column.HasExplicitPadding;\n\n        _columns.Add(column);\n\n        return this;\n    }\n\n    /// <summary>\n    /// Adds a new row to the grid.\n    /// </summary>\n    /// <param name=\"columns\">The columns to add.</param>\n    /// <returns>The same instance so that multiple calls can be chained.</returns>\n    public Grid AddRow(params IRenderable[] columns)\n    {\n        ArgumentNullException.ThrowIfNull(columns);\n\n        if (columns.Length > _columns.Count)\n        {\n            throw new InvalidOperationException(\"The number of row columns are greater than the number of grid columns.\");\n        }\n\n        _rows.Add(new GridRow(columns));\n        return this;\n    }\n\n    /// <inheritdoc/>\n    protected override bool HasDirtyChildren()\n    {\n        return _columns.Any(c => ((IHasDirtyState)c).IsDirty);\n    }\n\n    /// <inheritdoc/>\n    protected override IRenderable Build()\n    {\n        var table = new Table\n        {\n            Expand = Expand,","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/spectreconsole/spectre.console/blob/0acc92fada6c42f13984e79c2b5f3d993bdfb099/src/Spectre.Console/Widgets/Grid.cs#L71-L107","documentation":"Thrown by Grid.AddRow when the number of IRenderable columns passed exceeds the number of columns registered via AddColumn. Each row must not have more cells than the grid has columns.","triggerScenarios":"Calling AddRow with more arguments than the count of AddColumn calls previously made.","commonSituations":"Mistakenly passing extra items, a data-driven loop adding more values than configured columns, or forgetting to add a required column.","solutions":["Count the registered columns and ensure each row has that many or fewer items.","Add the missing columns before adding the row.","Trim the row items to match the column count."],"exampleFix":"// before\nvar grid = new Grid().AddColumn();\ngrid.AddRow(new Text(\"a\"), new Text(\"b\")); // throws: 2 > 1\n\n// after\nvar grid = new Grid().AddColumn().AddColumn();\ngrid.AddRow(new Text(\"a\"), new Text(\"b\"));","handlingStrategy":"validation","validationCode":"if (rowItems.Length > grid.Columns.Count()) throw new InvalidOperationException(\"Row has too many items\");\ngrid.AddRow(rowItems);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Register all needed columns before adding rows.","Assert row item count equals column count before AddRow."],"tags":["grid","invalid-operation","count-mismatch","spectre-console"],"backgroundTag":null,"analyzedSha":"0acc92fada6c42f13984e79c2b5f3d993bdfb099","analyzedAt":"2026-08-13T18:27:21.983Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}