{"record":{"id":"296968b045568157","repo":"dotnet/machinelearning","slug":"strings-indexisgreaterthancolumnlength","errorCode":null,"errorMessage":"Strings.IndexIsGreaterThanColumnLength","messagePattern":"Strings\\.IndexIsGreaterThanColumnLength","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.Data.Analysis/DataFrameColumns/ArrowStringDataFrameColumn.cs","lineNumber":224,"sourceCode":"                    _nullBitMapBuffers.Add(new DataFrameBuffer<byte>());\n                    mutableOffsetsBuffer = new DataFrameBuffer<int>();\n                    _offsetsBuffers.Add(mutableOffsetsBuffer);\n                    mutableOffsetsBuffer.Append(0);\n                }\n                var startIndex = mutableDataBuffer.Length;\n                mutableDataBuffer.IncreaseSize(value.Length);\n                value.CopyTo(mutableDataBuffer.RawSpan.Slice(startIndex));\n                mutableOffsetsBuffer.Append(mutableOffsetsBuffer[mutableOffsetsBuffer.Length - 1] + value.Length);\n            }\n            SetValidityBit(Length - 1, !value.IsEmpty);\n\n        }\n\n        private int GetBufferIndexContainingRowIndex(long rowIndex, out int indexInBuffer)\n        {\n            if (rowIndex >= Length)\n            {\n                throw new ArgumentOutOfRangeException(Strings.IndexIsGreaterThanColumnLength, nameof(rowIndex));\n            }\n\n            // Since the strings here could be of variable length, scan linearly\n            int curArrayIndex = 0;\n            int numBuffers = _offsetsBuffers.Count;\n            while (curArrayIndex < numBuffers && rowIndex > _offsetsBuffers[curArrayIndex].Length - 1)\n            {\n                rowIndex -= _offsetsBuffers[curArrayIndex].Length - 1;\n                curArrayIndex++;\n            }\n            indexInBuffer = (int)rowIndex;\n            return curArrayIndex;\n        }\n\n        private ReadOnlySpan<byte> GetBytes(long index)\n        {\n            int offsetsBufferIndex = GetBufferIndexContainingRowIndex(index, out int indexInBuffer);\n            ReadOnlySpan<int> offsetBufferSpan = _offsetsBuffers[offsetsBufferIndex].ReadOnlySpan;","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.Data.Analysis/DataFrameColumns/ArrowStringDataFrameColumn.cs#L206-L242","documentation":"GetBufferIndexContainingRowIndex locates which internal buffer holds a given row and throws ArgumentOutOfRangeException(Strings.IndexIsGreaterThanColumnLength, nameof(rowIndex)) when rowIndex >= Length. Note the arguments are swapped, so the exception message shows the library's message text rather than the parameter name. ArrowStringDataFrameColumn stores data across multiple buffers, and every per-row access funnels through this method.","triggerScenarios":"Any row access (indexer, GetValue, GetValues, ToArrowArray with startIndex) at or beyond the column's Length — e.g. reading index == Length, iterating with stale length, or passing a row index from a parent DataFrame whose row count exceeds this column.","commonSituations":"Ragged columns after Clone/append with fewer rows than expected; using DataFrame.Rows.Count on a column that was created shorter; loops bounded by a cached length captured before the column changed.","solutions":["Validate rowIndex < column.Length before access and clamp or throw a domain-specific error.","Re-read column.Length at loop time instead of caching it.","Check how the column was constructed (Clone(numberOfNullsToAppend), buffers) if it is shorter than expected.","If the swapped message text appears ('Index is greater than column length'), still treat it as an index-bounds problem on rowIndex."],"exampleFix":"// before\nvar v = arrowCol[someRow.Index]; // someRow from a longer frame\n\n// after\nif (someRow.Index < arrowCol.Length)\n    var v = arrowCol[someRow.Index];","handlingStrategy":"validation","validationCode":"if (rowIndex < 0 || rowIndex >= column.Length)\n    throw new ArgumentOutOfRangeException(nameof(rowIndex), \"Index is greater than column length\");","typeGuard":"static bool HasRow(ArrowStringDataFrameColumn c, long i) => i >= 0 && i < c.Length;","tryCatchPattern":"try { var v = column[rowIndex]; }\ncatch (ArgumentOutOfRangeException) { /* handle missing row: use default or skip */ }","preventionTips":["Validate row index against column.Length (not DataFrame row count)","Re-read Length instead of caching stale values","Remember the swapped message args: this throw reports the message text as paramName","Guard cross-column joins on per-column lengths"],"tags":["dotnet","dataframe","argument-out-of-range","indexing"],"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"}