{"record":{"id":"c4768d97c24f9193","repo":"dotnet/machinelearning","slug":"strings-mapindicesexceedscolumnlength-c4768d","errorCode":null,"errorMessage":"Strings.MapIndicesExceedsColumnLength","messagePattern":"Strings\\.MapIndicesExceedsColumnLength","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.Data.Analysis/DataFrameColumns/VBufferDataFrameColumn.cs","lineNumber":215,"sourceCode":"\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)\n        {\n            mapIndices = mapIndices ?? throw new ArgumentNullException(nameof(mapIndices));\n            var ret = new VBufferDataFrameColumn<T>(Name, mapIndices.Length);\n\n            long rowIndex = 0;\n            for (int b = 0; b < mapIndices.ColumnContainer.Buffers.Count; b++)\n            {","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.Data.Analysis/DataFrameColumns/VBufferDataFrameColumn.cs#L197-L233","documentation":"CloneImplementation(PrimitiveDataFrameColumn<bool> boolColumn) uses the bool column as a filter map, so it must not be longer than the source column; when boolColumn.Length > Length it throws ArgumentException(Strings.MapIndicesExceedsColumnLength, nameof(boolColumn)). Reached via Clone when mapIndices is a bool column.","triggerScenarios":"Calling Clone(mapIndices) where mapIndices is a PrimitiveDataFrameColumn<bool> with more entries than the VBufferDataFrameColumn being cloned.","commonSituations":"Filter masks built from a longer DataFrame reused against a shorter column; mask columns that grew after earlier appends; combining columns of differing lengths.","solutions":["Trim the bool mask to the column's Length before cloning.","Build the mask from the same column/DataFrame so lengths always match.","Assert boolColumn.Length <= column.Length before calling Clone.","Use a long/int index column instead of a bool mask when lengths may differ."],"exampleFix":"// before\nvar clone = column.Clone(mask); // mask.Length > column.Length\n// after\nif (mask.Length > column.Length)\n    throw new ArgumentException(\"Mask longer than column\");\nvar clone = column.Clone(mask);","handlingStrategy":"validation","validationCode":"if (mask is PrimitiveDataFrameColumn<bool> boolMask && boolMask.Length > column.Length)\n    throw new ArgumentException(\"Bool mask longer than column\");","typeGuard":"bool isValidMask(PrimitiveDataFrameColumn<bool> mask, DataFrameColumn col) => mask.Length <= col.Length;","tryCatchPattern":"try { var clone = column.Clone(mask); }\ncatch (ArgumentException ex) when (ex.ParamName == \"boolColumn\")\n{ /* mask longer than column: trim mask */ }","preventionTips":["Build filter masks from the same column being cloned.","Trim masks to column length before use.","Assert mask.Length <= column.Length in tests.","Prefer long index maps over bool masks in new code."],"tags":["argument-exception","dataframe","clone","length-mismatch"],"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-23T08:17:48.524Z"}