stride3d/stride · error · YamlException
ex.Message
Error message
ex.Message
What it means
DefaultObjectSerializerBackend.ReadYaml wraps any exception thrown while reading a YAML node value in a YamlException carrying the node's start/end coordinates. The original message (ex.Message) is preserved as the inner/outer message after unwrapping aggregate/target-invocation wrappers.
Solutions
- Read the inner exception message in the YamlException to find the real cause
- Fix the offending scalar value in the YAML document at the reported node location
- Ensure the target property type matches the YAML value format
- Use SerializerContext.AllowErrors to skip malformed values instead of failing hard
Example fix
// before size: big // property is int -> conversion exception wrapped in YamlException // after size: 42
Defensive patterns
Strategy: try-catch
Validate before calling
// Validate scalars against target types before deserializing
foreach (var (key, valueText) in yamlFields)
if (!valueConverter.CanConvert(key, valueText))
throw new YamlException(key, $"Value '{valueText}' invalid for {key}"); Try / catch
try
{
backend.ReadYaml(ref objectContext);
}
catch (YamlException ex)
{
logger.LogError(ex, "YAML read failed at {Start}-{End}: {Inner}", ex.Start, ex.End, ex.InnerException?.Message);
} Prevention
- Match YAML scalar formats to property types (culture-invariant numbers, valid GUIDs/dates)
- Inspect InnerException for the root cause
- Use AllowErrors for lenient deserialization of untrusted files
When it happens
Trigger: Any failure during node conversion for a member value, collection item, dictionary key or value: malformed scalars for the target type, converter exceptions, nested serializer failures. Callers: ReadMemberValue, ReadCollectionItem, ReadDictionaryKey, ReadDictionaryValue.
Common situations: Typos in numeric/enum scalar values; culture-dependent decimal formats; invalid GUIDs or date formats; exceptions thrown by property setters or converters during assignment.
Related errors
- ex.Message
- Multiple identifiable objects with the same id
- Unable to decode asset part reference
- Unable to deserialize reference
- Unable to find class from tag
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/0b7f781dded8f547.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Serialization/Serializers/DefaultObjectSerializerBackend.cs:188
/// <inheritdoc/>
public virtual bool ShouldSerialize(IMemberDescriptor member, ref ObjectContext objectContext) => member.ShouldSerialize(objectContext.Instance, objectContext.ParentTypeMemberDescriptor);
protected object ReadYaml(ref ObjectContext objectContext)
{
var node = objectContext.SerializerContext.Reader.Parser.Current;
try
{
return objectContext.SerializerContext.Serializer.ObjectSerializer.ReadYaml(ref objectContext);
}
catch (YamlException)
{
throw;
}
catch (Exception ex)
{
ex = ex.Unwrap();
throw new YamlException(node, ex);
}
}
protected void WriteYaml(ref ObjectContext objectContext)
{
objectContext.SerializerContext.Serializer.ObjectSerializer.WriteYaml(ref objectContext);
}
}
}
View on GitHub (pinned to 96fad776d2)