tursodatabase/turso · error · InvalidOperationException
CalledOnNullValue(ordinal)
Error message
CalledOnNullValue(ordinal)
What it means
Sentinel thrown by GetManagedTypedValue when a strongly-typed getter (GetInt32, GetString, etc.) hits a NULL column on the managed result set. The CalledOnNullValue(ordinal) resource string marks a null-value access; the faulting input is the ordinal of a column whose value is DBNull.
Source
Thrown at bindings/dotnet/src/Turso.Data.Sqlite/SqliteDataReader.cs:999
{
EnsureHasManagedCurrentRow();
ValidateOrdinal(ordinal);
var value = CurrentManagedResult.Rows[_managedRowIndex][ordinal] ?? DBNull.Value;
if (value != DBNull.Value
&& IsGuidType(CurrentManagedResult.Columns[ordinal].DataTypeName)
&& value is string or byte[])
{
return ToGuid(value);
}
return value;
}
private object GetManagedTypedValue(int ordinal)
{
var value = GetManagedValue(ordinal);
if (value == DBNull.Value)
throw new InvalidOperationException(Properties.Resources.CalledOnNullValue(ordinal));
return value;
}
private object? GetFirstManagedNonNullValue(int ordinal)
{
ValidateOrdinal(ordinal);
foreach (var row in CurrentManagedResult.Rows)
{
var value = row[ordinal];
if (value is not null && value != DBNull.Value)
return value;
}
return null;
}
private DataTable GetManagedSchemaTable()View on GitHub (pinned to 6c72522679)
Solutions
- Check IsDBNull(ordinal) before calling the typed getter
- Use the nullable/weakly-typed GetValue and handle DBNull.Value yourself
- Fix the query with IFNULL/COALESCE so the column cannot be NULL when a non-null type is required
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at bindings/dotnet/src/Turso.Data.Sqlite/SqliteDataReader.cs:999 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tursodatabase/turso@6c72522679 (2026-09-06).
Data as JSON: /api/errors/7dcf2473bddee702.
Report an issue: GitHub.