{"record":{"id":"f809d51696786782","repo":"dotnet/machinelearning","slug":"duplicate-column-name-duplicatecolname-is-presen","errorCode":null,"errorMessage":"Duplicate column name {duplicateColName} is present in two or more distinct properties of provided column information","messagePattern":"Duplicate column name (.+?) is present in two or more distinct properties of provided column information","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs","lineNumber":144,"sourceCode":"\n            ValidateColumnInfoEnumerationProperty(columnInformation.CategoricalColumnNames, CategoricalColumnPurposeName);\n            ValidateColumnInfoEnumerationProperty(columnInformation.NumericColumnNames, NumericColumnPurposeName);\n            ValidateColumnInfoEnumerationProperty(columnInformation.TextColumnNames, TextColumnPurposeName);\n            ValidateColumnInfoEnumerationProperty(columnInformation.IgnoredColumnNames, IgnoredColumnPurposeName);\n\n            // keep a list of all columns, to detect duplicates\n            var allColumns = new List<string>();\n            allColumns.Add(columnInformation.LabelColumnName);\n            if (columnInformation.ExampleWeightColumnName != null) { allColumns.Add(columnInformation.ExampleWeightColumnName); }\n            if (columnInformation.CategoricalColumnNames != null) { allColumns.AddRange(columnInformation.CategoricalColumnNames); }\n            if (columnInformation.NumericColumnNames != null) { allColumns.AddRange(columnInformation.NumericColumnNames); }\n            if (columnInformation.TextColumnNames != null) { allColumns.AddRange(columnInformation.TextColumnNames); }\n            if (columnInformation.IgnoredColumnNames != null) { allColumns.AddRange(columnInformation.IgnoredColumnNames); }\n\n            var duplicateColName = FindFirstDuplicate(allColumns);\n            if (duplicateColName != null)\n            {\n                throw new ArgumentException($\"Duplicate column name {duplicateColName} is present in two or more distinct properties of provided column information\", nameof(columnInformation));\n            }\n        }\n\n        private static void ValidateColumnInfoEnumerationProperty(IEnumerable<string> columns, string columnPurpose)\n        {\n            if (columns?.Contains(null) == true)\n            {\n                throw new ArgumentException($\"Null column string was specified as {columnPurpose} in column information\");\n            }\n        }\n\n        private static void ValidateLabelColumn(string labelColumn)\n        {\n            if (labelColumn == null)\n            {\n                throw new ArgumentException(\"Provided label column cannot be null\");\n            }\n        }","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs#L126-L162","documentation":"Thrown by UserInputValidationUtil.ValidateColumnInformation when the same column name appears in two or more distinct ColumnInformation properties (e.g. both LabelColumnName and a text column name, or duplicated across categorical/text/ignored lists). Ambiguous column purposes cannot be resolved, so the input is rejected with the first duplicate name in the message.","triggerScenarios":"Constructing ColumnInformation where, say, LabelColumnName equals an entry of CategoricalColumnNames, or the same name listed in both TextColumnNames and IgnoredColumnNames, then calling experiment.Execute or the infer-columns API.","commonSituations":"Programmatically building column lists by concatenating purpose arrays without de-duplication; a config file where one column is listed under two purposes; typos causing an intended column to double as label.","solutions":["Ensure each column name appears in at most one ColumnInformation property","De-duplicate purpose lists before constructing ColumnInformation","If a column serves multiple roles intentionally, pick the primary purpose and remove it from other lists"],"exampleFix":"// before\nvar colInfo = new ColumnInformation {\n    LabelColumnName = \"Label\",\n    IgnoredColumnNames = new[] { \"Id\", \"Label\" } // Label duplicated -> ArgumentException\n};\n\n// after\nvar colInfo = new ColumnInformation {\n    LabelColumnName = \"Label\",\n    IgnoredColumnNames = new[] { \"Id\" }\n};","handlingStrategy":"validation","validationCode":"var all = new[] { colInfo.LabelColumnName, colInfo.UserIdColumnName, colInfo.ItemIdColumnName, colInfo.GroupIdColumnName }\n    .Concat(colInfo.CategoricalColumnNames ?? Enumerable.Empty<string>())\n    .Concat(colInfo.TextColumnNames ?? Enumerable.Empty<string>())\n    .Concat(colInfo.IgnoredColumnNames ?? Enumerable.Empty<string>())\n    .Where(n => n != null).ToList();\nif (all.Count != all.Distinct().Count()) throw new InvalidOperationException(\"Duplicate column across purposes\");","typeGuard":null,"tryCatchPattern":"try { var r = experiment.Execute(data, colInfo); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Duplicate column name\")) { /* log offending column from message and rebuild ColumnInformation */ }","preventionTips":["Build ColumnInformation programmatically with a single source of truth per column","De-duplicate purpose lists when merging configs","Add a unit test asserting each column appears in exactly one purpose"],"tags":["dotnet","mlnet","automl","column-information","validation"],"backgroundTag":"conflicting-config-options","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"}