{"record":{"id":"f7a6f6c1f04fd70a","repo":"dotnet/machinelearning","slug":"strings-mapindicesexceedscolumnlength-f7a6f6","errorCode":null,"errorMessage":"Strings.MapIndicesExceedsColumnLength","messagePattern":"Strings\\.MapIndicesExceedsColumnLength","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.Data.Analysis/DataFrameColumns/StringDataFrameColumn.cs","lineNumber":329,"sourceCode":"                    clone = CloneImplementation(mapIndices as PrimitiveDataFrameColumn<int>, invertMapIndices);\n                else\n                    clone = CloneImplementation(mapIndices as PrimitiveDataFrameColumn<bool>);\n\n                for (long i = 0; i < numberOfNullsToAppend; i++)\n                    clone.Append(null);\n            }\n            else\n            {\n                clone = Clone(numberOfNullsToAppend);\n            }\n\n            return clone;\n        }\n\n        private StringDataFrameColumn CloneImplementation(PrimitiveDataFrameColumn<bool> boolColumn)\n        {\n            if (boolColumn.Length > Length)\n                throw new ArgumentException(Strings.MapIndicesExceedsColumnLength, nameof(boolColumn));\n            StringDataFrameColumn ret = new StringDataFrameColumn(Name, 0);\n            for (long i = 0; i < boolColumn.Length; i++)\n            {\n                bool? value = boolColumn[i];\n                if (value.HasValue && value.Value)\n                    ret.Append(this[i]);\n            }\n            return ret;\n        }\n\n        private StringDataFrameColumn CloneImplementation(PrimitiveDataFrameColumn<int> mapIndices, bool invertMapIndices = false)\n        {\n            mapIndices = mapIndices ?? throw new ArgumentNullException(nameof(mapIndices));\n            var ret = new StringDataFrameColumn(Name, mapIndices.Length);\n\n            long rowIndex = 0;\n            for (int b = 0; b < mapIndices.ColumnContainer.Buffers.Count; b++)\n            {","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.Data.Analysis/DataFrameColumns/StringDataFrameColumn.cs#L311-L347","documentation":"CloneImplementation(boolColumn) uses the boolean column as a mask over this column; if the mask is longer than the column the mapping is undefined, so ArgumentException(MapIndicesExceedsColumnLength) is thrown.","triggerScenarios":"Calling Clone(boolMask) where boolMask.Length > column.Length; using a mask built for a longer DataFrame/column.","commonSituations":"Filtering a column with a predicate mask computed against a different (larger) dataset; reusing a cached mask after the source shrank.","solutions":["Trim the bool mask to the column's length before cloning","Verify mask.Length == column.Length (or <=) before calling Clone","Recompute the mask against the current column","Slice the mask to match: clone only the first N mask entries if intentional"],"exampleFix":"// before\ncolumn.Clone(maskThatIsLonger);\n// after\nif (maskThatIsLonger.Length > column.Length)\n    maskThatIsLonger = maskThatIsLonger.Slice(0, column.Length);\ncolumn.Clone(maskThatIsLonger);","handlingStrategy":"validation","validationCode":"if (boolColumn.Length > column.Length) throw new ArgumentException(\"Mask longer than column\");","typeGuard":"bool MaskFitsColumn(PrimitiveDataFrameColumn<bool> mask, long length) => mask.Length <= length;","tryCatchPattern":"try { var clone = column.Clone(mask); } catch (ArgumentException) { /* slice mask and retry */ }","preventionTips":["Recompute masks against the exact column being filtered","Trim or Slice masks to column length","Avoid reusing cached masks across datasets"],"tags":["argumentexception","map-indices","dataframe"],"backgroundTag":"invalid-argument-value","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"}