tursodatabase/turso · error · ArgumentException
Unsupported argument type: {value.GetType()}
Error message
Unsupported argument type: {value.GetType()} What it means
The client maps CLR objects to Hrana types via an explicit pattern match over a fixed set: null/DBNull, bool, integer types, float, double, decimal, string, char, Guid, DateTime, DateTimeOffset, byte[], and (ReadOnly)Memory<byte>. Any other runtime type falls to the default case and throws, naming the actual type in the message.
Source
Thrown at bindings/dotnet/src/Turso.Serverless.Client/HranaProtocol.cs:65
return new HranaValue { Type = "float", DoubleValue = (double)m };
case string s:
return new HranaValue { Type = "text", StringValue = s };
case char c:
return new HranaValue { Type = "text", StringValue = c.ToString() };
case Guid g:
return new HranaValue { Type = "text", StringValue = g.ToString() };
case DateTime dt:
return new HranaValue { Type = "text", StringValue = dt.ToString("o", CultureInfo.InvariantCulture) };
case DateTimeOffset dto:
return new HranaValue { Type = "text", StringValue = dto.ToString("o", CultureInfo.InvariantCulture) };
case byte[] bytes:
return new HranaValue { Type = "blob", BlobValue = bytes };
case ReadOnlyMemory<byte> memory:
return new HranaValue { Type = "blob", BlobValue = memory.ToArray() };
case Memory<byte> memory:
return new HranaValue { Type = "blob", BlobValue = memory.ToArray() };
default:
throw new ArgumentException($"Unsupported argument type: {value.GetType()}");
}
}
public object? Decode()
{
return Type switch
{
"null" => null,
"integer" => long.Parse(StringValue!, CultureInfo.InvariantCulture),
"float" => DoubleValue ?? 0d,
"text" => StringValue,
"blob" => BlobValue ?? [],
_ => null,
};
}
}
internal sealed class HranaValueConverter : JsonConverter<HranaValue>View on GitHub (pinned to 244cde92a7)
Solutions
- Convert the value to a supported type before binding: dateOnly.ToString("o"), timeSpan.TotalSeconds, (int)enumValue, poco.SomeProperty
- For byte-like data use byte[] or ReadOnlyMemory<byte>
- Update the Turso.Serverless.Client package — the supported set expands between releases
- Wrap unsupported types in a small ToHranaValue helper so conversions live in one place
Example fix
// before
cmd.Parameters.AddWithValue("@date", new DateOnly(2026, 8, 20)); // throws
// after
cmd.Parameters.AddWithValue("@date", new DateOnly(2026, 8, 20).ToString("o", CultureInfo.InvariantCulture)); Defensive patterns
Strategy: validation
Validate before calling
static readonly HashSet<Type> Supported = new(){ typeof(bool), typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(decimal), typeof(string), typeof(char), typeof(Guid), typeof(DateTime), typeof(DateTimeOffset), typeof(byte[]) };
if (value is not null && !Supported.Contains(value.GetType())) value = Convert.ToString(value, CultureInfo.InvariantCulture); Type guard
static bool IsSupportedHranaValue(object? value) => value is null or DBNull or bool or sbyte or byte or short or ushort or int or uint or long or ulong or float or double or decimal or string or char or Guid or DateTime or DateTimeOffset or byte[] or ReadOnlyMemory<byte> or Memory<byte>;
Try / catch
try { cmd.Parameters.AddWithValue("@p", value); } catch (ArgumentException ex) when (ex.Message.StartsWith("Unsupported argument type")) { cmd.Parameters.AddWithValue("@p", value!.ToString()); } Prevention
- Centralize parameter creation in one helper that converts unsupported types
- Convert DateOnly/TimeOnly/TimeSpan/enum values explicitly at the call site
- Watch client release notes for newly supported types and update the package before relying on them
When it happens
Trigger: Binding DateOnly, TimeOnly, TimeSpan, UInt128/Int128, an enum boxed as object, or a custom POCO via AddWithValue or a parameter dictionary. E.g. cmd.Parameters.AddWithValue("@d", new DateOnly(2026,1,1)).
Common situations: Newer BCL types the client version predates; enums arriving from generic code boxed as object; passing LINQ projections or anonymous objects as parameter values instead of their scalar properties.
Related errors
- Only finite numbers (not Infinity or NaN) can be passed as a
- Parameter type {valueType} is not supported
- Embedded replica sync is not supported yet by the .NET provi
- Embedded replica connections are not supported yet by the .N
- Sync Interval requires embedded replica support, which is no
AI-assisted analysis of tursodatabase/turso@244cde92a7 (2026-08-20).
Data as JSON: /api/errors/01cfece700a623cc.
Report an issue: GitHub.