clockworklabs/SpacetimeDB · error · InvalidOperationException
Unsupported special type
Error message
Unsupported special type {type} ({type.SpecialType}) What it means
GetTypeInfo maps a type symbol's SpecialType to a BSATN name; bool, the numeric types and string are handled explicitly. Any other Roslyn 'special' type — char (System_Char), decimal (System_Decimal), DateTime/DateTimeOffset (System_DateTime), nint/IntPtr — hits the default arm and throws InvalidOperationException, printing the symbol and its SpecialType.
Solutions
- Map to supported primitives: DateTime/DateTimeOffset -> long (unix µs) or the SDK timestamp type if available; decimal -> scaled long or double; char -> string or byte
- Replace nint/IntPtr with long
- Rebuild — the error is compile-time, so replacing the type clears it immediately
Example fix
// before
[SpacetimeDB.Table(Name = "player", Public = true)]
public partial struct Player {
public DateTime CreatedAt;
public decimal Balance;
public char Rank;
}
// after
[SpacetimeDB.Table(Name = "player", Public = true)]
public partial struct Player {
public long CreatedAtMicros; // unix microseconds
public long BalanceMicros; // scaled fixed-point
public string Rank;
} Defensive patterns
Strategy: validation
Validate before calling
// Compile-time by design: `dotnet build` fails while any schema type is unsupported. // Checklist to apply to every table/reducer member: // DateTime/DateTimeOffset -> long micros // decimal -> long (scaled) or double // char -> string | byte // nint/IntPtr -> long
Try / catch
// compile-time error: nothing to catch. Replace the type and rebuild.
Prevention
- Adopt project-wide conventions mapping BCL types to BSATN primitives
- Keep domain models separate from schema types and map explicitly
- Build early — the generator reports the exact symbol and SpecialType
When it happens
Trigger: Using char, decimal, DateTime, DateTimeOffset, nint/IntPtr (or other non-None special types) in a table column, reducer argument, or [SpacetimeDB.Type] member of a C# project processed by the BSATN generator.
Common situations: C# developers defaulting to DateTime for timestamps and decimal for money; EF/LINQ-style domain models pasted into SpacetimeDB schema types; char fields for single-letter codes.
Related errors
- Unsupported system type
- Unsupported type
- Unsupported type
- Enum does not have a [SpacetimeDB.Type] attribute
- Argument must be a I128
AI-assisted analysis of clockworklabs/SpacetimeDB@6dee26c6ef (2026-08-20).
Data as JSON: /api/errors/0b00830812a88d59.
Report an issue: GitHub.
Appendix: source
Thrown at crates/bindings-csharp/BSATN.Codegen/Utils.cs:138
return type switch
{
ITypeParameterSymbol typeParameter => MakeRwTypeParam(typeParameter.Name),
INamedTypeSymbol namedType => type.SpecialType switch
{
SpecialType.System_Boolean => "SpacetimeDB.BSATN.Bool",
SpecialType.System_SByte => "SpacetimeDB.BSATN.I8",
SpecialType.System_Byte => "SpacetimeDB.BSATN.U8",
SpecialType.System_Int16 => "SpacetimeDB.BSATN.I16",
SpecialType.System_UInt16 => "SpacetimeDB.BSATN.U16",
SpecialType.System_Int32 => "SpacetimeDB.BSATN.I32",
SpecialType.System_UInt32 => "SpacetimeDB.BSATN.U32",
SpecialType.System_Int64 => "SpacetimeDB.BSATN.I64",
SpecialType.System_UInt64 => "SpacetimeDB.BSATN.U64",
SpecialType.System_Single => "SpacetimeDB.BSATN.F32",
SpecialType.System_Double => "SpacetimeDB.BSATN.F64",
SpecialType.System_String => "SpacetimeDB.BSATN.String",
SpecialType.None => GetTypeInfoForNamedType(namedType),
_ => throw new InvalidOperationException(
$"Unsupported special type {type} ({type.SpecialType})"
),
},
IArrayTypeSymbol { ElementType: var elementType } => elementType.SpecialType
== SpecialType.System_Byte
? "SpacetimeDB.BSATN.ByteArray"
: $"SpacetimeDB.BSATN.Array<{elementType}, {GetTypeInfo(elementType)}>",
_ => throw new InvalidOperationException($"Unsupported type {type}"),
};
static string GetTypeInfoForNamedType(INamedTypeSymbol type)
{
if (type.TypeKind == Microsoft.CodeAnalysis.TypeKind.Error)
{
throw new UnresolvedTypeException(type);
}
if (type.TypeKind == Microsoft.CodeAnalysis.TypeKind.Enum)
{View on GitHub (pinned to 6dee26c6ef)