stride3d/stride · error · SyntaxErrorException
While parsing a tag, did not find expected tag URI.
Error message
While parsing a tag, did not find expected tag URI.
What it means
The YAML scanner (Scanner.ScanTag) finished reading a tag token but the accumulated tag text was empty, i.e. there was no tag URI after the handle. A YAML tag like '!!str' or '!foo' must contain a URI part, so the scanner throws a SyntaxErrorException tied to the parse position. This is a malformed-YAML input error, not a runtime API misuse.
Solutions
- Fix the YAML source so the tag has a URI, e.g. change 'key: !!' to 'key: !!str' or 'key: !MyType value'.
- If you did not intend a tag, remove the stray '!' characters entirely.
- Validate the YAML with a linter/parser before feeding it to Stride.Core.Yaml.
- Catch SyntaxErrorException in the deserialization call and surface the mark (line/column) to the user.
Example fix
// before (input.yaml) logo: !! // after (input.yaml) logo: !!str "data:image/png;base64,..."
Defensive patterns
Strategy: validation
Validate before calling
// C#
if (yamlText.Contains("!!") || System.Text.RegularExpressions.Regex.IsMatch(yamlText, @"!\s*[:\n]"))
throw new FormatException("YAML contains an empty tag '!'; a tag URI must follow the handle."); Try / catch
try { deserializer.Deserialize(reader, targetType); }
catch (SyntaxErrorException ex) { throw new YamlConfigException($"Malformed tag at line {ex.Start.Line}, col {ex.Start.Column}", ex); } Prevention
- Always write tags in full form: !!str, !!map, or !YourType.
- Lint YAML files in CI with a YAML parser before deployment.
- Avoid hand-editing tagged YAML; use templates that emit complete tags.
When it happens
Trigger: Parsing YAML text where a tag token starts with '!' but no URI characters follow before the tag ends (e.g. '!!' followed by whitespace, or '!' at end of input). Reached via Deserializer/Serializer deserialize calls on a YamlStream/EventReader.
Common situations: Hand-edited YAML config files with a truncated tag like 'key: !!' or 'key: !'; copy-paste corruption that dropped the tag suffix; templating that emitted an empty tag placeholder.
Related errors
- While parsing a quoted scalar, did not find expected…
- While scanning a directive, could not find expected…
- While scanning a tag, did not find expected '!'.
- Unable to load the given stream
- Invalid version dependency format. Unable to decode
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/5f6dbd98ecda4859.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Scanner.cs:2142
while (analyzer.IsAlpha() || analyzer.Check(";/?:@&=+$,.!~*'()[]%"))
{
// Check if it is a URI-escape sequence.
if (analyzer.Check('%'))
{
tag.Append(ScanUriEscapes(start));
}
else
{
tag.Append(ReadCurrentCharacter());
}
}
// Check if the tag is non-empty.
if (tag.Length == 0)
{
throw new SyntaxErrorException(start, mark, "While parsing a tag, did not find expected tag URI.");
}
return tag.ToString();
}
/// <summary>
/// Decode an URI-escape sequence corresponding to a single UTF-8 character.
/// </summary>
private char ScanUriEscapes(Mark start)
{
// Decode the required number of characters.
List<byte> charBytes = new List<byte>();
int width = 0;
do
{
// Check for a URI-escaped octet.
View on GitHub (pinned to 96fad776d2)