stride3d/stride · error · SyntaxErrorException
While scanning a %YAML directive, did not find expected…
Error message
While scanning a %YAML directive, did not find expected digit or '.' character.
What it means
Thrown by the YAML Scanner while parsing the version number of a %YAML directive. After the major version digits the scanner requires a '.' before the minor version; if the next character is not a '.' (or a digit was missing) the directive is malformed.
Solutions
- Fix the directive to full 'major.minor' form: '%YAML 1.1' or '%YAML 1.2'.
- Remove the %YAML directive entirely if version declaration is unnecessary (the parser defaults to 1.1).
- Regenerate the file from its source/template if it was truncated.
- Validate with a YAML parser before loading to catch directive typos early.
Example fix
// before %YAML 1 --- // after %YAML 1.1 ---
Defensive patterns
Strategy: validation
Validate before calling
bool IsValidYamlVersionDirective(string line) =>
!line.StartsWith("%YAML") ||
System.Text.RegularExpressions.Regex.IsMatch(line, "^%YAML \\d+\\.\\d+\\s*$"); Try / catch
try
{
var obj = Deserializer.FromFile(path);
}
catch (SyntaxErrorException ex)
{
Log.Error(ex, "Bad %YAML version at line {Line}", ex.Start.Line);
throw new YamlConfigException("%YAML directive must be 'major.minor'", ex);
} Prevention
- Always write the full version: '%YAML 1.1' or '%YAML 1.2'
- Omit the %YAML directive when the default version is acceptable
- Lint YAML files in CI to catch directive typos
When it happens
Trigger: Parsing YAML whose %YAML directive has a malformed version, e.g. '%YAML 1' (no dot/minor), '%YAML x.y' (non-digit major), or '%YAML 1.1.1' style corruption where the expected '.' is absent.
Common situations: Hand-edited version directives; tools writing '%YAML 1' instead of '%YAML 1.1'; truncated files cut off mid-directive.
Related errors
- Found incompatible YAML document.
- While scanning a directive, find uknown directive name.
- While scanning a directive, did not find expected comment…
- While scanning a directive, could not find expected…
- While scanning a directive, find unexpected…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/f353f30d430276fd.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Scanner.cs:2054
/// Scan the value of VERSION-DIRECTIVE.
///
/// Scope:
/// %YAML 1.1 # a comment \n
/// ^^^^^^
/// </summary>
private Token ScanVersionDirectiveValue(Mark start)
{
SkipWhitespaces();
// Consume the major version number.
int major = ScanVersionDirectiveNumber(start);
// Eat '.'.
if (!analyzer.Check('.'))
{
throw new SyntaxErrorException(start, mark, "While scanning a %YAML directive, did not find expected digit or '.' character.");
}
Skip();
// Consume the minor version number.
int minor = ScanVersionDirectiveNumber(start);
return new VersionDirective(new Version(major, minor), start, start);
}
/// <summary>
/// Scan the value of a TAG-DIRECTIVE token.
///
/// Scope:
/// %TAG !yaml! tag:yaml.org,2002: \n
/// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/// </summary>View on GitHub (pinned to 96fad776d2)