{"record":{"id":"859df43cd7264fbb","repo":"dotnet/machinelearning","slug":"strings-indexisgreaterthancolumnlength-859df4","errorCode":null,"errorMessage":"Strings.IndexIsGreaterThanColumnLength","messagePattern":"Strings\\.IndexIsGreaterThanColumnLength","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.Data.Analysis/DataFrameColumns/StringDataFrameColumn.cs","lineNumber":107,"sourceCode":"        {\n            var column = inPlace ? this : Clone();\n\n            for (long i = 0; i < column.Length; i++)\n            {\n                var value = column[i];\n\n                if (value != null)\n                    column[i] = func(value);\n            }\n\n            return column;\n        }\n\n        private int GetBufferIndexContainingRowIndex(long rowIndex)\n        {\n            if (rowIndex >= Length)\n            {\n                throw new ArgumentOutOfRangeException(Strings.IndexIsGreaterThanColumnLength, nameof(rowIndex));\n            }\n            return (int)(rowIndex / MaxCapacity);\n        }\n\n        protected override object GetValue(long rowIndex)\n        {\n            int bufferIndex = GetBufferIndexContainingRowIndex(rowIndex);\n            return _stringBuffers[bufferIndex][(int)(rowIndex % MaxCapacity)];\n        }\n\n        protected override IReadOnlyList<object> GetValues(long startIndex, int length)\n        {\n            var ret = new List<object>();\n            int bufferIndex = GetBufferIndexContainingRowIndex(startIndex);\n            int bufferOffset = (int)(startIndex % MaxCapacity);\n            while (ret.Count < length && bufferIndex < _stringBuffers.Count)\n            {\n                for (int i = bufferOffset; ret.Count < length && i < _stringBuffers[bufferIndex].Count; i++)","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.Data.Analysis/DataFrameColumns/StringDataFrameColumn.cs#L89-L125","documentation":"StringDataFrameColumn stores rows in fixed-capacity buffers; GetBufferIndexContainingRowIndex maps a logical row index to a buffer. It throws ArgumentOutOfRangeException when rowIndex >= the column's Length, i.e. you asked for a row that does not exist in this column.","triggerScenarios":"Accessing this[rowIndex] or bufferIndex with an index equal to or beyond the column's current row count; often from passing a 0-based index that is actually a count, or using a DataFrame with more rows than this column.","commonSituations":"Off-by-one loops (i <= Length), indexing after rows were removed, joining columns of mismatched lengths.","solutions":["Check rowIndex against column.Length before indexing","Ensure loops use strict less-than (i < column.Length)","Verify the column was fully populated (same row count as the DataFrame)","Wrap indexed access in try/catch for ArgumentOutOfRangeException in data-driven code"],"exampleFix":"// before\nvar value = column[column.Length];\n// after\nif (rowIndex >= 0 && rowIndex < column.Length)\n    var value = column[rowIndex];","handlingStrategy":"validation","validationCode":"if (rowIndex < 0 || rowIndex >= column.Length) throw new ArgumentOutOfRangeException(nameof(rowIndex));","typeGuard":"bool IsValidIndex(long i, long length) => i >= 0 && i < length;","tryCatchPattern":"try { var v = column[rowIndex]; } catch (ArgumentOutOfRangeException) { /* handle missing row */ }","preventionTips":["Always compare against column.Length before indexing","Use foreach or typed enumeration instead of manual indexing","Watch for off-by-one loops (i < Length, not <=)"],"tags":["index-out-of-range","dataframe","argumentoutofrangeexception"],"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"}