{"record":{"id":"6f36bda27f4828e8","repo":"stride3d/stride","slug":"while-scanning-a-tag-did-not-find-expected","errorCode":null,"errorMessage":"While scanning a tag, did not find expected '!'.","messagePattern":"While scanning a tag, did not find expected '!'\\.","errorType":"exception","errorClass":"SyntaxErrorException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Scanner.cs","lineNumber":2222,"sourceCode":"\n            if (characters.Length != 1)\n            {\n                throw new SyntaxErrorException(start, mark, \"While parsing a tag, find an incorrect UTF-8 sequence.\");\n            }\n\n            return characters[0];\n        }\n\n        /// <summary>\n        /// Scan a tag handle.\n        /// </summary>\n        private string ScanTagHandle(bool isDirective, Mark start)\n        {\n            // Check the initial '!' character.\n\n            if (!analyzer.Check('!'))\n            {\n                throw new SyntaxErrorException(start, mark, \"While scanning a tag, did not find expected '!'.\");\n            }\n\n            // Copy the '!' character.\n\n            StringBuilder tagHandle = new StringBuilder();\n            tagHandle.Append(ReadCurrentCharacter());\n\n            // Copy all subsequent alphabetical and numerical characters.\n\n            while (analyzer.IsAlpha())\n            {\n                tagHandle.Append(ReadCurrentCharacter());\n            }\n\n            // Check if the trailing character is '!' and copy it.\n\n            if (analyzer.Check('!'))\n            {","sourceCodeStart":2204,"sourceCodeEnd":2240,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Scanner.cs#L2204-L2240","documentation":"Scanner.ScanTagHandle requires a tag handle to begin with '!'. When the scanner decides the next token is a tag but the current character is not '!', the internal tokenization invariant is violated for this input and it throws SyntaxErrorException. Effectively this means the YAML text has a malformed tag construct at that position.","triggerScenarios":"Input where a tag was detected (e.g. after '&' anchor parsing or in a %TAG directive position) but the character at the mark is not '!', such as corrupted input or an off-by-position state from earlier malformed syntax.","commonSituations":"Corrupted or machine-mangled YAML; a tag directive line like '%TAG foo bar' missing the '!' in the handle; mixing dialects/editors that mangle '!' characters.","solutions":["Inspect the input at the reported line/column and restore the '!' of the tag handle (e.g. '!<tag:yaml.org,2002:str>').","Fix any earlier syntax error that put the scanner in the wrong state — the reported mark may be downstream of the real problem.","Validate the file with a standard YAML parser before loading.","Catch SyntaxErrorException to fail gracefully and surface the position to the user."],"exampleFix":"// before (input.yaml)\n%TAG tag:yaml.org,2002: type\n\n// after (input.yaml)\n%TAG !tag! tag:yaml.org,2002:","handlingStrategy":"try-catch","validationCode":"// C#\nif (!string.IsNullOrEmpty(yamlText) && yamlText.Contains(\"%TAG\"))\n{\n    foreach (var line in yamlText.Split('\\n').Where(l => l.StartsWith(\"%TAG\")))\n        if (!line.Contains(\"!\")) throw new FormatException($\"%TAG directive missing '!': {line.Trim()}\");\n}","typeGuard":null,"tryCatchPattern":"try { deserializer.Deserialize(reader, targetType); }\ncatch (SyntaxErrorException ex) { throw new YamlConfigException($\"Malformed tag handle at line {ex.Start.Line}, col {ex.Start.Column}\", ex); }","preventionTips":["Verify %TAG directives always include a '!' handle.","Run a YAML linter on generated files before loading.","When a position seems wrong, check preceding lines for earlier syntax errors."],"tags":["yaml","parsing","scanner"],"backgroundTag":"yaml-parse-error","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}