{"record":{"id":"f47fbc95592d7f04","repo":"dotnet/machinelearning","slug":"nameof-row","errorCode":null,"errorMessage":"nameof(row)","messagePattern":"nameof\\(row\\)","errorType":"exception","errorClass":"IndexOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.Data.Analysis/DataFrameColumns/StringDataFrameColumn.cs","lineNumber":525,"sourceCode":"        protected internal override void AddValueUsingCursor(DataViewRowCursor cursor, Delegate getter)\n        {\n            long row = cursor.Position;\n            ReadOnlyMemory<char> value = default;\n            Debug.Assert(getter != null, \"Excepted getter to be valid\");\n\n            (getter as ValueGetter<ReadOnlyMemory<char>>)(ref value);\n\n            if (Length > row)\n            {\n                this[row] = value.ToString();\n            }\n            else if (Length == row)\n            {\n                Append(value.ToString());\n            }\n            else\n            {\n                throw new IndexOutOfRangeException(nameof(row));\n            }\n        }\n\n        protected internal override Delegate GetValueGetterUsingCursor(DataViewRowCursor cursor, DataViewSchema.Column schemaColumn)\n        {\n            return cursor.GetGetter<ReadOnlyMemory<char>>(schemaColumn);\n        }\n\n        public override Dictionary<long, ICollection<long>> GetGroupedOccurrences(DataFrameColumn other, out HashSet<long> otherColumnNullIndices)\n        {\n            return GetGroupedOccurrences<string>(other, out otherColumnNullIndices);\n        }\n    }\n}\n","sourceCodeStart":507,"sourceCodeEnd":540,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.Data.Analysis/DataFrameColumns/StringDataFrameColumn.cs#L507-L540","documentation":"An IndexOutOfRangeException thrown at the end of StringDataFrameColumn.AddValueUsingCursor when the cursor's position (row) is greater than the column's current Length. The method accepts a row equal to Length (appending) or less than Length (overwriting in place), but a row beyond Length leaves a gap of uninitialized values, so it refuses by throwing with nameof(row) as the offending argument. It fires when a DataViewRowCursor is advanced further than the number of rows already materialized in the column — typically because rows were skipped or the column was not grown in lockstep with cursor iteration. Unlike the Debug.Assert(getter != null) guard earlier in the method (a debug-only sentinel for a null getter delegate), this is a runtime validation of the row index input, and the value at fault is cursor.Position relative to Length.","triggerScenarios":"Assigning via the object indexer at a row index greater than the current column length; sparse or skipped-index filling that leaves gaps.","commonSituations":"Building a column row-by-row with wrong bookkeeping; appending at assumed positions after row deletions; copying from a differently sized source.","solutions":["Use Append(value) for adding new rows instead of indexing past Length","Ensure indices are contiguous 0..Length-1 during construction","Check rowIndex <= Length before assigning; only rowIndex == Length appends","Pre-size the column (new StringDataFrameColumn(name, length)) then fill in order"],"exampleFix":"// before\ncolumn[column.Length + 1] = value; // gap -> throw\n// after\ncolumn.Append(value);","handlingStrategy":"validation","validationCode":"if (rowIndex > column.Length) throw new IndexOutOfRangeException($\"row {rowIndex} > length {column.Length}\");","typeGuard":"bool CanAssignAt(long i, long length) => i >= 0 && i <= length; // == length appends","tryCatchPattern":"try { column[rowIndex] = value; } catch (IndexOutOfRangeException) { column.Append(value); }","preventionTips":["Use Append for new rows, indexer only for existing rows","Build columns with contiguous indices","Pre-size the column and fill in order"],"tags":["index-out-of-range","indexoutofrangeexception","dataframe"],"backgroundTag":"index-out-of-range","analyzedSha":"7b76e69cf964daeca3f1377af6bc5543284d56c6","analyzedAt":"2026-09-11T12:35:38.930Z","contentChangedAt":"2026-09-11T12:35:38.930Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}