{"record":{"id":"a3ab05663c4026ad","repo":"dotnet/machinelearning","slug":"value-cannot-be-null-parameter-type","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'type')","messagePattern":"Value cannot be null\\. \\(Parameter 'type'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.ML.DataView/DataViewSchema.cs","lineNumber":115,"sourceCode":"            /// </summary>\n            public DataViewType Type { get; }\n\n            /// <summary>\n            /// The annotations of the column.\n            /// </summary>\n            public Annotations Annotations { get; }\n\n            internal Column(string name, int index, bool isHidden, DataViewType type, Annotations annotations)\n            {\n                if (string.IsNullOrEmpty(name))\n                    throw new ArgumentNullException(nameof(name));\n                if (index < 0)\n                    throw new ArgumentOutOfRangeException(nameof(index));\n\n                Name = name;\n                Index = index;\n                IsHidden = isHidden;\n                Type = type ?? throw new ArgumentNullException(nameof(type));\n                Annotations = annotations ?? Annotations.Empty;\n            }\n\n            public override string ToString()\n            {\n                var annotationsString = (Annotations == null || Annotations.Schema.Count == 0) ?\n                    null : $\" {{{string.Join(\", \", Annotations.Schema.Select(x => x.Name))}}}\";\n                return $\"{Name}: {Type}{annotationsString}\";\n            }\n        }\n\n        /// <summary>\n        /// This class represents the schema of one column of a data view, without an attachment to a particular <see cref=\"DataViewSchema\"/>.\n        /// </summary>\n        public struct DetachedColumn\n        {\n            /// <summary>\n            /// The name of the column.","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.ML.DataView/DataViewSchema.cs#L97-L133","documentation":"DataViewSchema.Column requires a non-null DataViewType; passing null for 'type' throws ArgumentNullException naming 'type'. The type object defines the column's data type and raw representation, so it is mandatory.","triggerScenarios":"Constructing a Column (or Builder.Add overload) with type == null — e.g. type inference failed upstream, a variable was never assigned, or a factory method returned null for an unsupported data kind.","commonSituations":"Type-mapping tables missing an entry for a source column type (returning null); loading metadata from files where a type declaration is absent; calling constructors directly instead of builder APIs that infer types.","solutions":["Ensure a concrete DataViewType (e.g. NumberType.R4, TextType, BooleanDataViewType) is passed; fix the null-producing factory/mapping.","Add an explicit fallback default type for unmapped source types instead of returning null.","Fail fast upstream with a clear message when type inference cannot determine a type.","Prefer builder APIs that compute the type from data rather than passing a raw type argument."],"exampleFix":"// before\nDataViewType t = typeMap[sourceKind]; // may return null\nvar column = new Column(name, index, false, t, null);\n// after\nDataViewType t = typeMap.TryGetValue(sourceKind, out var mapped) ? mapped : NumberType.R4;\nvar column = new Column(name, index, false, t, null);","handlingStrategy":"validation","validationCode":"if (type == null) throw new ArgumentException(\"Column type must be resolved before schema construction\");","typeGuard":"bool HasType(DataViewType t) => t != null;","tryCatchPattern":null,"preventionTips":["Ensure type maps have entries for every source type","Fail at the mapping site with a clear message instead of returning null"],"tags":["dotnet","null-argument","schema","constructor"],"backgroundTag":"null-argument","analyzedSha":"7b76e69cf964daeca3f1377af6bc5543284d56c6","analyzedAt":"2026-09-11T12:35:38.930Z","contentChangedAt":"2026-09-11T12:35:38.930Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}