stride3d/stride · error · AnchorNotFoundException
Unable to find alias
Error message
Unable to find alias
What it means
While reading YAML, an alias node like *anchorName was encountered, but the AnchorSerializer has no recorded object for that alias — the anchor (&name) was never defined earlier in the document or was not kept. This throws an AnchorNotFoundException carrying 'Unable to find alias'.
Solutions
- Fix the YAML so every alias has a preceding matching anchor definition (&name) in the same document
- Remove or inline the dangling alias if shared data is no longer needed
- Catch YamlException/AnchorNotFoundException during deserialization and report the document location
Example fix
// before (yaml)
value: *missingAnchor
// after (yaml)
base: &missingAnchor { x: 1 }
value: *missingAnchor Defensive patterns
Strategy: try-catch
Try / catch
try { return serializer.Deserialize(reader, type); } catch (YamlException ex) when (ex.InnerException is AnchorNotFoundException) { throw new InvalidDataException($"Dangling YAML alias at {ex.Start}-{ex.End}", ex); } Prevention
- Ensure every *alias has a preceding &anchor in the same document
- Avoid stripping anchors when merging or preprocessing YAML
- Prefer explicit inline data over cross-document aliases
When it happens
Trigger: Deserializing a YAML document containing `*alias` whose matching `&alias` anchor is absent, out of order, or stripped by preprocessing/merging of documents.
Common situations: Hand-edited YAML where an anchor was renamed/deleted; tooling that re-emits YAML without preserving anchors; concatenating YAML fragments where the anchor lives in another file.
Related errors
- Anchor value must contain alphanumerical characters only.
- Anchor value must not be empty.
- Cannot add item with key
- Cannot deserialize collection to readonly collection type
- Cannot deserialize collection to type
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/313af8097fb7c19b.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Serialization/Serializers/AnchorSerializer.cs:81
public bool TryGetAliasValue(string alias, out object value)
{
return aliasToObject.TryGetValue(alias, out value);
}
public override object ReadYaml(ref ObjectContext objectContext)
{
var context = objectContext.SerializerContext;
var reader = context.Reader;
object value = null;
// Process Anchor alias (*oxxx)
var alias = reader.Allow<AnchorAlias>();
if (alias != null)
{
// Return an alias or directly the value
if (!aliasToObject.TryGetValue(alias.Value, out value))
{
throw new AnchorNotFoundException(alias.Value, alias.Start, alias.End, "Unable to find alias");
}
return value;
}
// Test if current node has an anchor &oxxx
string anchor = null;
var nodeEvent = reader.Peek<NodeEvent>();
if (nodeEvent != null && !string.IsNullOrEmpty(nodeEvent.Anchor))
{
anchor = nodeEvent.Anchor;
}
// Deserialize the current node
value = base.ReadYaml(ref objectContext);
// Store Anchor (&oxxx) and override any defined anchor
if (anchor != null)
{View on GitHub (pinned to 96fad776d2)