{"record":{"id":"4a62ee3575fa1ace","repo":"dotnet/machinelearning","slug":"string-format-strings-multiplemismatchedvaluetype","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/StringDataFrameColumn.cs","lineNumber":307,"sourceCode":"        {\n            StringDataFrameColumn ret = new StringDataFrameColumn(Name, Length);\n            for (long i = 0; i < Length; i++)\n                ret[i] = this[i];\n\n            for (long i = 0; i < numberOfNullsToAppend; i++)\n                ret.Append(null);\n\n            return ret;\n        }\n\n        protected override DataFrameColumn CloneImplementation(DataFrameColumn mapIndices, bool invertMapIndices = false, long numberOfNullsToAppend = 0)\n        {\n            StringDataFrameColumn 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                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","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.Data.Analysis/DataFrameColumns/StringDataFrameColumn.cs#L289-L325","documentation":"When cloning a StringDataFrameColumn with mapIndices, the map indices column must be PrimitiveDataFrameColumn of long, int, or bool. Any other DataType throws ArgumentException with MultipleMismatchedValueType listing the three accepted types.","triggerScenarios":"Calling Clone(mapIndices) where mapIndices is a PrimitiveDataFrameColumn of e.g. float, double, decimal, or DateTime.","commonSituations":"Building a selection index with the wrong numeric type; deriving indices from computations that produced doubles; using float indices read from CSV parsing.","solutions":["Cast mapIndices to PrimitiveDataFrameColumn<long> (or int/bool) before calling Clone","Use a bool mask column (PrimitiveDataFrameColumn<bool>) for filtering","Create the indices column explicitly with long element type","Convert the indices column via Elementwise conversion before cloning"],"exampleFix":"// before\ncolumn.Clone(floatIndices);\n// after\nvar longIndices = new PrimitiveDataFrameColumn<long>(\"indices\", floatIndices.Length);\nfor (long i = 0; i < floatIndices.Length; i++) longIndices[i] = (long)floatIndices[i];\ncolumn.Clone(longIndices);","handlingStrategy":"validation","validationCode":"var t = mapIndices.DataType;\nif (t != typeof(long) && t != typeof(int) && t != typeof(bool))\n    throw new ArgumentException(\"mapIndices must be long, int, or bool\");","typeGuard":"bool IsValidMapIndices(DataFrameColumn c) =>\n    c is PrimitiveDataFrameColumn<long> || c is PrimitiveDataFrameColumn<int> || c is PrimitiveDataFrameColumn<bool>;","tryCatchPattern":"try { var clone = column.Clone(mapIndices); } catch (ArgumentException) { /* convert indices type and retry */ }","preventionTips":["Always build map index columns as long or bool","Avoid float/double index columns from numeric pipelines","Validate DataType before Clone"],"tags":["type-mismatch","argumentexception","clone","dataframe"],"backgroundTag":"type-mismatch","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"}