stride3d/stride · error · SyntaxErrorException
While scanning a %TAG directive, did not find expected…
Error message
While scanning a %TAG directive, did not find expected whitespace.
What it means
Thrown by the YAML Scanner when, after scanning the handle of a %TAG directive, the next character is not a whitespace. A %TAG directive must separate its handle and prefix with whitespace, e.g. '%TAG ! tag:example.com,2000:'.
Solutions
- Insert a space between the tag handle and the tag URI prefix: '%TAG !e! tag:example.com,2000:'.
- Remove the %TAG directive if tag shorthand is not needed and use full tag URIs inline.
- Check for missing spaces caused by aggressive whitespace stripping in a build/minify step.
- Validate the file with yamllint or an online YAML parser before deployment.
Example fix
// before %TAG!e!tag:example.com,2000: --- // after %TAG !e! tag:example.com,2000: ---
Defensive patterns
Strategy: validation
Validate before calling
bool IsValidTagDirective(string line) =>
!line.StartsWith("%TAG") ||
System.Text.RegularExpressions.Regex.IsMatch(line, "^%TAG\\s+!?[!A-Za-z0-9-]*!\\s+\\S+"); Try / catch
try
{
var obj = Deserializer.FromText(yaml);
}
catch (SyntaxErrorException ex)
{
Log.Error(ex, "Missing whitespace in %TAG directive at line {Line}", ex.Start.Line);
throw;
} Prevention
- Keep a space between handle and prefix: '%TAG !e! tag:example.com,2000:'
- Avoid whitespace-stripping/minification steps on YAML files
- Validate tag directives with a reference parser before deployment
When it happens
Trigger: Parsing YAML with a %TAG directive missing the space between handle and prefix, e.g. '%TAG!!foo:' or '%TAG!e!tag:example.com'.
Common situations: Minified or hand-compressed YAML where spaces were stripped; typos merging the handle with the prefix; generated tag directives from buggy writers.
Related errors
- While scanning a %TAG directive, did not find expected…
- Found duplicate %TAG directive.
- 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…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/3c96d93c303c44d6.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Scanner.cs:2085
/// Scan the value of a TAG-DIRECTIVE token.
///
/// Scope:
/// %TAG !yaml! tag:yaml.org,2002: \n
/// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/// </summary>
private Token ScanTagDirectiveValue(Mark start)
{
SkipWhitespaces();
// Scan a handle.
string handle = ScanTagHandle(true, start);
// Expect a whitespace.
if (!analyzer.IsBlank())
{
throw new SyntaxErrorException(start, mark, "While scanning a %TAG directive, did not find expected whitespace.");
}
SkipWhitespaces();
// Scan a prefix.
string prefix = ScanTagUri(null, start);
// Expect a whitespace or line break.
if (!analyzer.IsBlankOrBreakOrZero())
{
throw new SyntaxErrorException(start, mark, "While scanning a %TAG directive, did not find expected whitespace or line break.");
}
return new TagDirective(handle, prefix, start, start);
}
View on GitHub (pinned to 96fad776d2)