{"record":{"id":"25e3f43af25d3fd4","repo":"dotnet/machinelearning","slug":"name","errorCode":null,"errorMessage":"name","messagePattern":"name","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.ML.DataView/DataViewSchema.cs","lineNumber":298,"sourceCode":"                    {\n                        if (selector(column.Name))\n                            _items.Add((column.Name, column.Type, annotations.GetGetterInternal(column.Index), column.Annotations));\n                    }\n                }\n\n                /// <summary>\n                /// Add one annotation column, strongly-typed version.\n                /// </summary>\n                /// <typeparam name=\"TValue\">The type of the value.</typeparam>\n                /// <param name=\"name\">The annotation name.</param>\n                /// <param name=\"type\">The annotation type.</param>\n                /// <param name=\"getter\">The getter delegate.</param>\n                /// <param name=\"annotations\">Annotations of the input column. Note that annotations on an annotation column is somewhat rare\n                /// except for certain types (for example, slot names for a vector, key values for something of key type).</param>\n                public void Add<TValue>(string name, DataViewType type, ValueGetter<TValue> getter, Annotations annotations = null)\n                {\n                    if (string.IsNullOrEmpty(name))\n                        throw new ArgumentNullException(nameof(name));\n                    if (type == null)\n                        throw new ArgumentNullException(nameof(type));\n                    if (getter == null)\n                        throw new ArgumentNullException(nameof(getter));\n                    if (type.RawType != typeof(TValue))\n                        throw new ArgumentException($\"{nameof(type)}.{nameof(type.RawType)} must be of type '{typeof(TValue).FullName}'.\", nameof(type));\n\n                    _items.Add((name, type, getter, annotations));\n                }\n\n                /// <summary>\n                /// Add one annotation column, weakly-typed version.\n                /// </summary>\n                /// <param name=\"name\">The annotation name.</param>\n                /// <param name=\"type\">The annotation type.</param>\n                /// <param name=\"getter\">The getter delegate that provides the value. Note that the type of the getter is still checked\n                /// inside this method.</param>\n                /// <param name=\"annotations\">Annotations of the input column. Note that annotations on an annotation column is somewhat rare","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.ML.DataView/DataViewSchema.cs#L280-L316","documentation":"The strongly-typed Builder.Add<TValue> validates that the column name is non-null and non-empty before adding the annotation/column entry; an empty string or null name is rejected with ArgumentNullException 'name'. Every column and annotation must have an identifying name.","triggerScenarios":"Passing string.Empty as a name; passing a name variable that came from a failed lookup or split operation and is null; building output schema in a custom transform with placeholder names never filled in.","commonSituations":"Dynamically generated column names from feature/label configuration where the user left the setting blank; constructing slot-name or key-value annotations with empty kind strings.","solutions":["Validate the name string before calling Add (non-null, non-empty)","Default to a meaningful name (e.g. the input column name) when the source value is blank","Throw your own descriptive error earlier so the user sees which config field was blank"],"exampleFix":"// before\nbuilder.Add(name, type, getter);\n// after\nif (string.IsNullOrEmpty(name))\n    throw new InvalidOperationException(\"Column name must be provided\");\nbuilder.Add(name, type, getter);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(name))\n    throw new ArgumentException(\"Column name required\", nameof(name));\nbuilder.Add(name, type, getter);","typeGuard":null,"tryCatchPattern":"try { builder.Add(name, type, getter); }\ncatch (ArgumentNullException e) when (e.ParamName == \"name\")\n{\n    builder.Add(fallbackName ?? \"Column0\", type, getter);\n}","preventionTips":["Validate user-supplied column-name config before building the schema","Default missing names to a derived value (e.g. input column name)","Never construct entries with string.Empty as a placeholder"],"tags":["dotnet","mlnet","argument-null","schema-builder"],"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"}