stride3d/stride · error · YamlException
Anchor value must not be empty.
Error message
Anchor value must not be empty.
What it means
AnchorAlias events represent *x references to an anchor; the alias value must be a non-empty string matching the anchor grammar. The constructor throws this YamlException (with position marks) when the alias value is null or empty, before any parsing/emitting proceeds.
Solutions
- Pass the actual anchor name to the AnchorAlias constructor
- Validate that the anchor string is non-empty before constructing the event
- Skip emitting the alias (emit the anchored node inline instead) when no anchor name exists
- Fix the upstream code that produced the empty anchor reference
Example fix
// before
var alias = new AnchorAlias(aliasName, start, end);
// after
if (string.IsNullOrEmpty(aliasName)) throw new InvalidOperationException("Alias name missing");
var alias = new AnchorAlias(aliasName, start, end); Defensive patterns
Strategy: validation
Validate before calling
bool ok = !string.IsNullOrEmpty(aliasName);
if (!ok) throw new ArgumentException("Alias name is required"); Try / catch
try { var alias = new AnchorAlias(name, start, end); }
catch (YamlException ex) when (ex.Message.Contains("must not be empty")) { /* emit the node inline instead of an alias */ } Prevention
- Never interpolate anchor names from data that may be empty
- Skip aliases when the anchor name was lost and inline the node instead
- Validate anchor references when converting from other formats
When it happens
Trigger: new AnchorAlias("", start, end) or new AnchorAlias(null, start, end); alias nodes generated from deserialized data where the anchor name was lost or empty.
Common situations: Programmatic construction of YAML event graphs; pipelines that convert anchors/aliases from other formats and lose the name; templates that interpolate an anchor variable which resolved to an empty string.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Anchor value must contain alphanumerical characters only.
- Anchor value must contain alphanumerical characters only.
- Anchor value must not be empty.
- Unable to find alias
- A serializer factory selector must be sealed before being…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/b4cb0f3433a696a6.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Events/AnchorAlias.cs:85
private readonly string value;
/// <summary>
/// Gets the value of the alias.
/// </summary>
public string Value { get { return value; } }
/// <summary>
/// Initializes a new instance of the <see cref="AnchorAlias"/> class.
/// </summary>
/// <param name="value">The value of the alias.</param>
/// <param name="start">The start position of the event.</param>
/// <param name="end">The end position of the event.</param>
public AnchorAlias(string value, Mark start, Mark end)
: base(start, end)
{
if (string.IsNullOrEmpty(value))
{
throw new YamlException(start, end, "Anchor value must not be empty.");
}
if (!NodeEvent.anchorValidator.IsMatch(value))
{
throw new YamlException(start, end, "Anchor value must contain alphanumerical characters only.");
}
this.value = value;
}
/// <summary>
/// Initializes a new instance of the <see cref="AnchorAlias"/> class.
/// </summary>
/// <param name="value">The value of the alias.</param>
public AnchorAlias(string value)
: this(value, Mark.Empty, Mark.Empty)
{
}View on GitHub (pinned to 96fad776d2)