{"record":{"id":"afb19acdc6fd3069","repo":"dotnet/machinelearning","slug":"nameof-row-afb19a","errorCode":null,"errorMessage":"nameof(row)","messagePattern":"nameof\\(row\\)","errorType":"exception","errorClass":"IndexOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.Data.Analysis/DataFrameColumns/VBufferDataFrameColumn.cs","lineNumber":208,"sourceCode":"        protected internal override void AddValueUsingCursor(DataViewRowCursor cursor, Delegate getter)\n        {\n            long row = cursor.Position;\n            VBuffer<T> value = default;\n            Debug.Assert(getter != null, \"Excepted getter to be valid\");\n\n            (getter as ValueGetter<VBuffer<T>>)(ref value);\n\n            if (Length > row)\n            {\n                this[row] = value;\n            }\n            else if (Length == row)\n            {\n                Append(value);\n            }\n            else\n            {\n                throw new IndexOutOfRangeException(nameof(row));\n            }\n        }\n\n        private VBufferDataFrameColumn<T> CloneImplementation(PrimitiveDataFrameColumn<bool> boolColumn)\n        {\n            if (boolColumn.Length > Length)\n                throw new ArgumentException(Strings.MapIndicesExceedsColumnLength, nameof(boolColumn));\n            VBufferDataFrameColumn<T> ret = new VBufferDataFrameColumn<T>(Name, 0);\n            for (long i = 0; i < boolColumn.Length; i++)\n            {\n                bool? value = boolColumn[i];\n                if (value.HasValue && value.Value == true)\n                    ret.Append(this[i]);\n            }\n            return ret;\n        }\n\n        private VBufferDataFrameColumn<T> CloneImplementation(PrimitiveDataFrameColumn<long> mapIndices, bool invertMapIndices = false)","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.Data.Analysis/DataFrameColumns/VBufferDataFrameColumn.cs#L190-L226","documentation":"AddValueUsingCursor appends to the column only when the cursor's row position equals the column Length; any other position throws IndexOutOfRangeException(nameof(row)). The column is append-only during cursor consumption, so 'row' must track the next append slot exactly.","triggerScenarios":"Calling AddValueUsingCursor with row < Length (slot already filled) or row > Length (gap) — e.g. a cursor that skips rows, or calling it twice for the same row.","commonSituations":"Custom IDataView-to-DataFrame conversion code with a row counter out of sync with the column; appending into a column that already holds data; parallel cursors writing to one column.","solutions":["Ensure the cursor visits rows sequentially 0..Length-1 and the method is called exactly once per row.","Append filler/default rows so row == Length when the value arrives.","Use a fresh column when re-reading data instead of appending to a populated one.","Guard the call: only invoke when row equals the column's current Length."],"exampleFix":"// before\ncolumn.AddValueUsingCursor(cursor, row); // row != column.Length\n// after\nif (row == column.Length)\n    column.AddValueUsingCursor(cursor, row);\nelse\n    throw new InvalidOperationException($\"Expected row {column.Length}, got {row}\");","handlingStrategy":"validation","validationCode":"if (row != column.Length)\n    throw new InvalidOperationException($\"AddValueUsingCursor requires row == Length ({column.Length}), got {row}\");","typeGuard":"bool canAppendAt(long row, VBufferDataFrameColumn<T> col) => row == col.Length;","tryCatchPattern":"try { column.AddValueUsingCursor(cursor, row); }\ncatch (IndexOutOfRangeException)\n{ /* cursor out of sync with column: resync or recreate column */ }","preventionTips":["Consume cursors strictly sequentially, one call per row.","Never append to a column that already contains data.","Use a fresh column per read pass.","Assert row == Length in debug builds."],"tags":["index-out-of-range","dataframe","cursor","append-only"],"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"}