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

  1. Fix the YAML source so the tag has a URI, e.g. change 'key: !!' to 'key: !!str' or 'key: !MyType value'.
  2. If you did not intend a tag, remove the stray '!' characters entirely.
  3. Validate the YAML with a linter/parser before feeding it to Stride.Core.Yaml.
  4. 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

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


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)