stride3d/stride · error · YamlException
Unable to decode scalar
Error message
Unable to decode scalar [{scalar}] not supported by current schema What it means
PrimitiveSerializer.ConvertFrom throws this when it cannot decode a YAML scalar into any of the primitive types supported by the current schema. After running through the TypeCode switch and the tagged-scalar handling, if no conversion applies it fails with the scalar's start/end position.
Solutions
- Check the target type/registered schema supports the scalar's type; register a custom serializer if needed.
- Remove or correct the unsupported YAML tag on the scalar.
- Add the type to TypeSerializerFactory registrations so a proper serializer is selected.
- Inspect the scalar's tag in the YAML and map it via the tag registry.
Example fix
// before myValue: !!weirdtag something // after (or register a serializer for the type) myValue: 42
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-scan YAML for tags before deserializing
foreach (var tag in ExtractTags(yamlText))
if (!KnownTags.Contains(tag)) throw new InvalidOperationException($"Unsupported tag {tag}"); Try / catch
try { return serializer.Deserialize(data); } catch (YamlException ex) { log.LogError(ex, "Unsupported scalar at {Start}-{End}: {Message}", ex.Start, ex.End, ex.Message); throw; } Prevention
- Register serializers for all custom types in the schema before deserializing.
- Avoid exotic YAML tags from other language ecosystems (.py, .rb tags).
- Keep tag registry and assembly registrations in sync with model types.
- Validate documents with a strict parser before deserialization.
When it happens
Trigger: Calling the deserializer on a scalar node whose target type (or resolved tag) maps to a primitive the serializer does not handle, e.g. an exotic TypeCode, a type not registered in the schema, or a scalar used where no compatible primitive conversion exists.
Common situations: Schema/type mismatch after renaming or removing a type; a YAML tag (like !!python/object or a custom tag) the .NET schema does not understand; deserializing into object and letting an unsupported tag drive conversion.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Multiple identifiable objects with the same id
- Unable to decode asset part reference
- Unable to deserialize reference
- Unable to find class from tag
- Unable to find property
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/819673b7e5512b22.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Serialization/Serializers/PrimitiveSerializer.cs:162
case TypeCode.Decimal:
return decimal.Parse(text, CultureInfo.InvariantCulture);
}
// If we are expecting a type object, return directly the string
if (type == typeof(object))
{
// Try to parse the scalar directly
string defaultTag;
object scalarValue;
if (context.SerializerContext.Schema.TryParse(scalar, true, out defaultTag, out scalarValue))
{
return scalarValue;
}
return text;
}
throw new YamlException(scalar.Start, scalar.End, $"Unable to decode scalar [{scalar}] not supported by current schema");
}
/// <summary>
/// Appends decimal point to arg if it does not exist
/// </summary>
/// <param name="text"></param>
/// <param name="hasNaN">True if the floating point type supports NaN or Infinity.</param>
/// <returns></returns>
private static string AppendDecimalPoint(string text, bool hasNaN)
{
for (var i = 0; i < text.Length; i++)
{
var c = text[i];
// Do not append a decimal point if floating point type value
// - is in exponential form, or
// - already has a decimal point
if (c == 'e' || c == 'E' || c == '.')
{View on GitHub (pinned to 96fad776d2)