clockworklabs/SpacetimeDB · error · ArgumentOutOfRangeException
Value {value} is out of range for enum {typeof(T).Name}
Error message
Value {value} is out of range for enum {typeof(T).Name} What it means
Error "Value {value} is out of range for enum {typeof(T).Name}" thrown in clockworklabs/SpacetimeDB.
Source
Thrown at crates/bindings-csharp/BSATN.Runtime/BSATN/Runtime.cs:172
// This was quite expensive because:
// 1. It uses reflection
// 2. It allocates
// 3. It is called on each row when decoding
//
// However, enum values are guaranteed to be sequential and zero based.
// Hence we only ever need to do an upper bound check.
// See `SpacetimeDB.Type.ParseEnum` for the syntax analysis.
//
// Note: this actually still uses reflection and allocates.
// It's hard to figure out how to avoid this without custom-generating a writer for each enum type.
var tag = Convert.ToByte(value);
if (tag < TagToValue.Length)
{
writer.Write(tag);
}
else
{
throw new ArgumentOutOfRangeException(
$"Value {value} is out of range for enum {typeof(T).Name}"
);
}
}
public AlgebraicType GetAlgebraicType(ITypeRegistrar registrar) =>
registrar.RegisterType<T>(
(_) =>
new AlgebraicType.Sum(
#pragma warning disable CA2263 // netstandard2.1 lacks the generic Enum overloads.
[
.. Enum.GetNames(typeof(T))
.Select(name => new AggregateElement(name, AlgebraicType.Unit)),
]
#pragma warning restore CA2263
)
);
}View on GitHub (pinned to 524b4487d9)
When it happens
Trigger: Thrown at crates/bindings-csharp/BSATN.Runtime/BSATN/Runtime.cs:172 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16).
Data as JSON: /api/errors/b0595cab65a8da78.
Report an issue: GitHub.