dotnet/machinelearning · error · ArgumentException

column

Error message

column

What it means

Annotations.GetGetter<TValue> throws ArgumentException naming 'column' when the requested column's Index is outside the annotations' internal getter array (column.Index >= _getters.Length). It means the column does not belong to this annotations schema or the wrong Annotations object was queried.

Solutions

  1. Only pass columns that belong to the annotations' own schema; verify column.Schema identity/annotation membership before calling.
  2. Guard with column.Index < annotations.Schema.Count (or an equivalent bounds check) before requesting the getter.
  3. Get the Annotations from the correct column: annotations for column C are typically reached via C.Annotations.
  4. If copying between schemas, remap indices to the target schema instead of reusing the source column.

Example fix

// before
var getter = sourceCol.Annotations.GetGetter<VBuffer<float>>(someOtherSchemaColumn); // Index out of range
// after
if (someOtherSchemaColumn.Index < sourceCol.Annotations.Schema.Count)
{
    var getter = sourceCol.Annotations.GetGetter<VBuffer<float>>(sourceCol.Annotations.Schema[someOtherSchemaColumn.Index]);
}
else { /* column has no such annotation */ }
Defensive patterns

Strategy: validation

Validate before calling

bool canGet = column.Index < annotations.Schema.Count;

Type guard

bool AnnotationExists(DataViewSchema.Column col, int annotationIndex) => annotationIndex < col.Annotations.Schema.Count;

Try / catch

try { var g = col.Annotations.GetGetter<TValue>(annCol); } catch (ArgumentException) { /* annotation not present for this column */ }

Prevention

When it happens

Trigger: Calling annotations.GetGetter<TValue>(column) with a column from a different schema whose Index exceeds the annotation getter count, or with an annotation column index computed against a larger schema.

Common situations: Requesting metadata (e.g. slot names) for a column in schema A using the Annotations object of column in schema B after a transform changed columns; iterating all schema columns and querying annotations for each without checking membership.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at src/Microsoft.ML.DataView/DataViewSchema.cs:224

                }
                Schema = schema;
                _getters = getters;
            }

            private void CheckGetter<TValue>(Delegate getter)
            {
                var typedGetter = getter as ValueGetter<TValue>;
                if (typedGetter == null)
                    throw new ArgumentNullException(nameof(getter), $"Getter of type '{typeof(TValue)}' expected, but {getter.GetType()} found");
            }

            /// <summary>
            /// Get a getter delegate for one value of the annotations row.
            /// </summary>
            public ValueGetter<TValue> GetGetter<TValue>(DataViewSchema.Column column)
            {
                if (column.Index >= _getters.Length)
                    throw new ArgumentException(nameof(column));
                var typedGetter = _getters[column.Index] as ValueGetter<TValue>;
                if (typedGetter == null)
                {
                    Debug.Assert(_getters[column.Index] != null);
                    throw new InvalidOperationException($"Invalid call to '{nameof(GetGetter)}'");
                }
                return typedGetter;
            }

            /// <summary>
            /// Get the value of an annotation, by annotation kind (aka column name).
            /// </summary>
            public void GetValue<TValue>(string kind, ref TValue value)
            {
                var column = Schema.GetColumnOrNull(kind);
                if (column == null)
                    throw new InvalidOperationException($"Invalid call to '{nameof(GetValue)}'");
                GetGetter<TValue>(column.Value)(ref value);

View on GitHub (pinned to 7b76e69cf9)