{"record":{"id":"5061a393cc06cfc9","repo":"dotnet/machinelearning","slug":"strings-indexisgreaterthancolumnlength-5061a3","errorCode":null,"errorMessage":"Strings.IndexIsGreaterThanColumnLength","messagePattern":"Strings\\.IndexIsGreaterThanColumnLength","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.Data.Analysis/DataFrameColumns/VBufferDataFrameColumn.cs","lineNumber":86,"sourceCode":"        }\n\n        public void Append(VBuffer<T> value)\n        {\n            List<VBuffer<T>> lastBuffer = _vBuffers[_vBuffers.Count - 1];\n            if (lastBuffer.Count == MaxCapacity)\n            {\n                lastBuffer = new List<VBuffer<T>>();\n                _vBuffers.Add(lastBuffer);\n            }\n            lastBuffer.Add(value);\n            Length++;\n        }\n\n        private int GetBufferIndexContainingRowIndex(long rowIndex)\n        {\n            if (rowIndex >= Length)\n            {\n                throw new ArgumentOutOfRangeException(Strings.IndexIsGreaterThanColumnLength, nameof(rowIndex));\n            }\n\n            return (int)(rowIndex / MaxCapacity);\n        }\n\n        protected override object GetValue(long rowIndex)\n        {\n            return GetTypedValue(rowIndex);\n        }\n\n        protected VBuffer<T> GetTypedValue(long rowIndex)\n        {\n            int bufferIndex = GetBufferIndexContainingRowIndex(rowIndex);\n            return _vBuffers[bufferIndex][(int)(rowIndex % MaxCapacity)];\n        }\n\n        protected override IReadOnlyList<object> GetValues(long startIndex, int length)\n        {","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.Data.Analysis/DataFrameColumns/VBufferDataFrameColumn.cs#L68-L104","documentation":"Like the string column, VBufferDataFrameColumn<T> shards its rows into MaxCapacity-sized buffers; GetBufferIndexContainingRowIndex throws ArgumentOutOfRangeException when rowIndex >= Length because no buffer holds that row.","triggerScenarios":"Object indexer get or bufferIndex call with rowIndex beyond the column's Length; reading a row from an empty column.","commonSituations":"Enumerating with i <= Length off-by-one; column not yet populated but reader assumes final size; mismatched DataFrame row counts.","solutions":["Validate rowIndex < Length before indexing","Fix loop bounds to strict less-than","Populate/Resize the column before reading","Catch ArgumentOutOfRangeException at boundaries where lengths are dynamic"],"exampleFix":"// before\nvar v = column[column.Length];\n// after\nvar v = rowIndex < column.Length ? column[rowIndex] : default(VBuffer<T>);","handlingStrategy":"validation","validationCode":"if (rowIndex < 0 || rowIndex >= column.Length) throw new ArgumentOutOfRangeException(nameof(rowIndex));","typeGuard":"bool IsValidVBufferIndex(long i, long length) => i >= 0 && i < length;","tryCatchPattern":"try { var v = column[rowIndex]; } catch (ArgumentOutOfRangeException) { /* row absent; use default buffer */ }","preventionTips":["Validate indices against Length before access","Ensure the column is fully populated before reading","Prefer typed enumerators over manual index math"],"tags":["index-out-of-range","argumentoutofrangeexception","vbuffer"],"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-14T11:17:12.474Z"}