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 or line break.
What it means
Thrown by the YAML Scanner when, after scanning the tag URI prefix of a %TAG directive, the next character is not a whitespace, line break, or end of input. The directive must terminate with whitespace or a break; trailing garbage (like a second token glued to the prefix) is rejected.
Solutions
- Ensure the tag prefix is followed by whitespace or a newline before anything else on the line.
- Remove any stray characters directly after the prefix URI.
- Move subsequent content onto its own line after the directive.
- Pre-validate the YAML (yamllint) in CI so malformed directives are caught before parsing.
Example fix
// before %TAG !e! tag:example.com,2000:extra // after %TAG !e! tag:example.com,2000:
Defensive patterns
Strategy: validation
Validate before calling
// %TAG line must end after the prefix (whitespace/linebreak only)
bool TagDirectiveLineTerminates(string line) =>
!line.StartsWith("%TAG") ||
System.Text.RegularExpressions.Regex.IsMatch(line, "^%TAG\\s+\\S+\\s+\\S+\\s*$"); Try / catch
try
{
var obj = Deserializer.FromFile(path);
}
catch (SyntaxErrorException ex)
{
Log.Error(ex, "Trailing garbage after %TAG prefix at line {Line}", ex.Start.Line);
throw new YamlConfigException("%TAG prefix must be followed by whitespace or line break", ex);
} Prevention
- Put each %TAG directive on its own line, ending right after the prefix
- Watch for trailing punctuation (',', ')') introduced by copy-paste
- Run yamllint in CI on all YAML artifacts
When it happens
Trigger: Parsing YAML with a %TAG directive whose prefix is immediately followed by another non-space token, e.g. '%TAG !e! tag:example.com,2000:extra-token' with no separating whitespace, or characters like ',' or ')' directly after the prefix.
Common situations: Multiple tokens merged by whitespace stripping; trailing punctuation from surrounding text (e.g. prefix pasted with a trailing comma); typos concatenating the prefix with the next directive or document content.
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/30460ac91475b429.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Scanner.cs:2098
// 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);
}
/// <summary>
/// Scan a tag.
/// </summary>
private string ScanTagUri(string head, Mark start)
{
StringBuilder tag = new StringBuilder();
if (head != null && head.Length > 1)
{
tag.Append(head.Substring(1));
}
// Scan the tag.
View on GitHub (pinned to 96fad776d2)