dotnet/machinelearning · error · ArgumentNullException

null

Error message

null

What it means

Guard in the StringDataFrameColumn(string name, long length) constructor path when a required input is null. The constructor allocates length-bounded string buffers and fills them with default (null) entries; a null argument (for example a null name passed down to the base DataFrameColumn constructor, or later null-related operations on the pre-filled null slots) is rejected with a standard ArgumentNullException-style guard.

Source

Thrown at src/Microsoft.Data.Analysis/DataFrameColumns/StringDataFrameColumn.cs:43

        public StringDataFrameColumn(string name, long length = 0) : base(name, length, typeof(string))
        {
            int numberOfBuffersRequired = (int)(length / MaxCapacity + 1);
            for (int i = 0; i < numberOfBuffersRequired; i++)
            {
                long bufferLen = length - _stringBuffers.Count * MaxCapacity;
                List<string> buffer = new List<string>((int)Math.Min(MaxCapacity, bufferLen));
                _stringBuffers.Add(buffer);
                for (int j = 0; j < bufferLen; j++)
                {
                    buffer.Add(default);
                }
            }
            _nullCount = length;
        }

        public StringDataFrameColumn(string name, IEnumerable<string> values) : base(name, 0, typeof(string))
        {
            values = values ?? throw new ArgumentNullException(nameof(values));
            if (_stringBuffers.Count == 0)
            {
                _stringBuffers.Add(new List<string>());
            }
            foreach (var value in values)
            {
                Append(value);
            }
        }

        private long _nullCount;
        public override long NullCount => _nullCount;

        protected internal override void Resize(long length)
        {
            if (length < Length)
                throw new ArgumentException(Strings.CannotResizeDown, nameof(length));

View on GitHub (pinned to 7b76e69cf9)

Solutions

  1. Pass a non-null column name when constructing StringDataFrameColumn
  2. If the value can legitimately be absent, supply string.Empty instead of null
  3. Validate inputs before constructing the column in data-loading code
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/Microsoft.Data.Analysis/DataFrameColumns/StringDataFrameColumn.cs:43 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of dotnet/machinelearning@7b76e69cf9 (2026-09-11). Data as JSON: /api/errors/f382dcf45305d626. Report an issue: GitHub.