{"record":{"id":"66f0ee82b3aec063","repo":"dotnet/machinelearning","slug":"value-cannot-be-null-parameter-input","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'input')","messagePattern":"Value cannot be null\\. \\(Parameter 'input'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.ML.CodeGenerator/Utils.cs","lineNumber":142,"sourceCode":"            {\n                var f = val as bool?;\n                return f.GetValueOrDefault() ? \"true\" : \"false\";\n            }\n\n            return val.ToString();\n        }\n\n        internal static string Normalize(string input)\n        {\n            //check if first character is int\n            if (!string.IsNullOrEmpty(input) && int.TryParse(input.Substring(0, 1), out int val))\n            {\n                input = \"_\" + input;\n                return Normalize(input);\n            }\n            switch (input)\n            {\n                case null: throw new ArgumentNullException(nameof(input));\n                case \"\": throw new ArgumentException($\"{nameof(input)} cannot be empty\", nameof(input));\n                default:\n                    var sanitizedInput = Sanitize(input);\n                    return sanitizedInput.First().ToString().ToUpper() + sanitizedInput.Substring(1);\n            }\n        }\n\n        internal static Type GetCSharpType(DataKind labelType)\n        {\n            switch (labelType)\n            {\n                case Microsoft.ML.Data.DataKind.String:\n                    return typeof(string);\n                case Microsoft.ML.Data.DataKind.Boolean:\n                    return typeof(bool);\n                case Microsoft.ML.Data.DataKind.Single:\n                    return typeof(float);\n                case Microsoft.ML.Data.DataKind.Double:","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.ML.CodeGenerator/Utils.cs#L124-L160","documentation":"Utils.Normalize converts a string into a valid C# identifier (sanitizing, prefixing, capitalizing). Passing null reaches the switch on input and throws ArgumentNullException('input'). The library requires a non-null string because it must produce a valid identifier name for generated code.","triggerScenarios":"Calling Utils.Normalize(null) directly, or indirectly when a column/metadata name used to derive an identifier is null (e.g. a schema column with null name passed through code generation helpers that call Normalize).","commonSituations":"Data files with missing/blank header names producing null column names; programmatic PipelineNode/slot-name construction where the name field was never set; codegen invoked on a schema whose text metadata is absent.","solutions":["Ensure the name source is non-null before calling Normalize; supply a fallback name when the column/metadata name is missing.","Check your input data headers — replace empty/null headers with valid names.","If calling Normalize directly, guard with string.IsNullOrWhiteSpace before the call.","Catch ArgumentNullException and substitute a generated placeholder name."],"exampleFix":"// before\nvar identifier = Utils.Normalize(columnName);\n// after\nvar identifier = Utils.Normalize(columnName ?? \"Column_\" + index);","handlingStrategy":"validation","validationCode":"if (name is null)\n    throw new InvalidOperationException(\"Column name was null; check data source headers\");\nvar identifier = Utils.Normalize(name);","typeGuard":"static bool IsNormalizable(string s) => !string.IsNullOrEmpty(s);","tryCatchPattern":"try\n{\n    identifier = Utils.Normalize(rawName);\n}\ncatch (ArgumentNullException)\n{\n    identifier = \"UnnamedColumn\";\n}","preventionTips":["Ensure data files have no missing/blank header cells.","Coalesce null names to defaults before any codegen step.","Validate schema column names during data load, not at generation time.","Prefer string.IsNullOrWhiteSpace checks over null-only checks."],"tags":["csharp","null-argument","identifier","codegen"],"backgroundTag":"null-argument","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"}