{"record":{"id":"10725a1da28525e8","repo":"dotnet/machinelearning","slug":"null-values-are-not-supported-by-vbufferdataframec","errorCode":null,"errorMessage":"Null values are not supported by VBufferDataFrameColumn","messagePattern":"Null values are not supported by VBufferDataFrameColumn","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.Data.Analysis/DataFrameColumns/VBufferDataFrameColumn.cs","lineNumber":124,"sourceCode":"            int bufferIndex = GetBufferIndexContainingRowIndex(startIndex);\n            int bufferOffset = (int)(startIndex % MaxCapacity);\n            while (ret.Count < length && bufferIndex < _vBuffers.Count)\n            {\n                for (int i = bufferOffset; ret.Count < length && i < _vBuffers[bufferIndex].Count; i++)\n                {\n                    ret.Add(_vBuffers[bufferIndex][i]);\n                }\n                bufferIndex++;\n                bufferOffset = 0;\n            }\n            return ret;\n        }\n\n        protected override void SetValue(long rowIndex, object value)\n        {\n            if (value == null)\n            {\n                throw new NotSupportedException(\"Null values are not supported by VBufferDataFrameColumn\");\n            }\n            else if (value is VBuffer<T> vbuffer)\n            {\n                SetTypedValue(rowIndex, vbuffer);\n            }\n            else\n            {\n                throw new ArgumentException(string.Format(Strings.MismatchedValueType, typeof(VBuffer<T>)), nameof(value));\n            }\n        }\n\n        protected void SetTypedValue(long rowIndex, VBuffer<T> value)\n        {\n            int bufferIndex = GetBufferIndexContainingRowIndex(rowIndex);\n            _vBuffers[bufferIndex][(int)(rowIndex % MaxCapacity)] = value;\n        }\n\n        public new VBuffer<T> this[long rowIndex]","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.Data.Analysis/DataFrameColumns/VBufferDataFrameColumn.cs#L106-L142","documentation":"Guard in VBufferDataFrameColumn.SetValue: this column type stores VBuffer<T> values with no representation for missing data (NullCount is hard-coded to 0), so setting a slot to null is unsupported and throws. The caller must supply a valid (possibly empty) VBuffer<T> instead.","triggerScenarios":"Assigning null via the object indexer or SetValue(rowIndex, null); generic row-copy code that passes null through for missing values.","commonSituations":"Copying from a nullable column with nulls into a VBuffer column; generic DataFrame transformation that doesn't special-case VBuffer columns.","solutions":["Provide a default VBuffer<T>.Empty (or a zero-length buffer) instead of null","Filter or replace nulls in the source before copying","Use DropNulls / null checks on the source column first","Use a supported nullable column type if nulls are truly required"],"exampleFix":"// before\ncolumn[rowIndex] = null;\n// after\ncolumn[rowIndex] = VBuffer<T>.Empty;","handlingStrategy":"type-guard","validationCode":"if (value is null) throw new NotSupportedException(\"VBufferDataFrameColumn does not accept nulls\");","typeGuard":"bool IsAssignableVBuffer(object v) => v is VBuffer<T>;","tryCatchPattern":"try { column[rowIndex] = value; } catch (NotSupportedException) { column[rowIndex] = VBuffer<T>.Empty; }","preventionTips":["Replace nulls with VBuffer<T>.Empty before assignment","Sanitize source columns (DropNulls) before copying into VBuffer columns","Remember VBuffer columns have NullCount == 0 by design"],"tags":["notsupported","null-value","vbuffer"],"backgroundTag":"unsupported-operation","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"}