{"record":{"id":"954809b473d6fe73","repo":"dotnet/machinelearning","slug":"string-format-strings-multiplemismatchedvaluetype-954809","errorCode":null,"errorMessage":"String.Format(Strings.MultipleMismatchedValueType, typeof(long), typeof(int), typeof(bool))","messagePattern":"String\\.Format\\(Strings\\.MultipleMismatchedValueType, typeof\\(long\\), typeof\\(int\\), typeof\\(bool\\)\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.Data.Analysis/DataFrameColumns/VBufferDataFrameColumn.cs","lineNumber":287,"sourceCode":"\n        public new VBufferDataFrameColumn<T> Clone(DataFrameColumn mapIndices, bool invertMapIndices, long numberOfNullsToAppend)\n        {\n            return (VBufferDataFrameColumn<T>)CloneImplementation(mapIndices, invertMapIndices, numberOfNullsToAppend);\n        }\n\n        public new VBufferDataFrameColumn<T> Clone(long numberOfNullsToAppend = 0)\n        {\n            return (VBufferDataFrameColumn<T>)CloneImplementation(numberOfNullsToAppend);\n        }\n\n        protected override DataFrameColumn CloneImplementation(DataFrameColumn mapIndices, bool invertMapIndices = false, long numberOfNullsToAppend = 0)\n        {\n            VBufferDataFrameColumn<T> clone;\n            if (!(mapIndices is null))\n            {\n                Type dataType = mapIndices.DataType;\n                if (dataType != typeof(long) && dataType != typeof(int) && dataType != typeof(bool))\n                    throw new ArgumentException(String.Format(Strings.MultipleMismatchedValueType, typeof(long), typeof(int), typeof(bool)), nameof(mapIndices));\n                if (mapIndices.DataType == typeof(long))\n                    clone = CloneImplementation(mapIndices as PrimitiveDataFrameColumn<long>, invertMapIndices);\n                else if (dataType == typeof(int))\n                    clone = CloneImplementation(mapIndices as PrimitiveDataFrameColumn<int>, invertMapIndices);\n                else\n                    clone = CloneImplementation(mapIndices as PrimitiveDataFrameColumn<bool>);\n            }\n            else\n            {\n                clone = Clone();\n            }\n\n            return clone;\n        }\n\n        protected override DataFrameColumn CloneImplementation(long numberOfNullsToAppend)\n        {\n            var ret = new VBufferDataFrameColumn<T>(Name, Length);","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.Data.Analysis/DataFrameColumns/VBufferDataFrameColumn.cs#L269-L305","documentation":"When Clone receives a non-null mapIndices column, its DataType must be long, int, or bool; any other element type throws ArgumentException with Strings.MultipleMismatchedValueType listing the three supported types, paramName mapIndices. Only these three map column types have cloning implementations.","triggerScenarios":"Calling Clone(mapIndices, invertMapIndices) with a PrimitiveDataFrameColumn of another type (short, byte, float, decimal, string) or any non-primitive column.","commonSituations":"Index lists produced elsewhere as float/double; CSV-parsed indices typed wrong; generic helper code passing whatever column it holds.","solutions":["Convert the map to PrimitiveDataFrameColumn<long> (or int/bool) before cloning.","Build the map explicitly: new PrimitiveDataFrameColumn<long>(\"indices\", indices).","Keep filter maps bool and index maps long by convention.","Check mapIndices.DataType against typeof(long)/typeof(int)/typeof(bool) before calling Clone."],"exampleFix":"// before\ncolumn.Clone(floatIndices); // PrimitiveDataFrameColumn<float>\n// after\nvar longIndices = new PrimitiveDataFrameColumn<long>(\"indices\",\n    Enumerable.Range(0, (int)floatIndices.Length).Select(i => (long)floatIndices[i]));\ncolumn.Clone(longIndices);","handlingStrategy":"validation","validationCode":"var t = mapIndices?.DataType;\nbool ok = t == typeof(long) || t == typeof(int) || t == typeof(bool);\nif (mapIndices != null && !ok) throw new ArgumentException(\"mapIndices must be long, int, or bool\");","typeGuard":"bool isValidMapIndices(DataFrameColumn m) =>\n    m is null || m.DataType == typeof(long) || m.DataType == typeof(int) || m.DataType == typeof(bool);","tryCatchPattern":"try { var clone = column.Clone(mapIndices); }\ncatch (ArgumentException ex) when (ex.ParamName == \"mapIndices\")\n{ /* convert mapIndices to PrimitiveDataFrameColumn<long> and retry */ }","preventionTips":["Standardize index maps on PrimitiveDataFrameColumn<long>.","Convert other numeric types to long before cloning.","Check DataType before calling Clone.","Avoid float/double index columns."],"tags":["argument-exception","dataframe","clone","unsupported-type"],"backgroundTag":"unsupported-operation","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"}