{"record":{"id":"30460ac91475b429","repo":"stride3d/stride","slug":"while-scanning-a-tag-directive-did-not-find-expected-scanner","errorCode":null,"errorMessage":"While scanning a %TAG directive, did not find expected whitespace or line break.","messagePattern":"While scanning a %TAG directive, did not find expected whitespace or line break\\.","errorType":"exception","errorClass":"SyntaxErrorException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Scanner.cs","lineNumber":2098,"sourceCode":"\n            // Expect a whitespace.\n\n            if (!analyzer.IsBlank())\n            {\n                throw new SyntaxErrorException(start, mark, \"While scanning a %TAG directive, did not find expected whitespace.\");\n            }\n\n            SkipWhitespaces();\n\n            // Scan a prefix.\n\n            string prefix = ScanTagUri(null, start);\n\n            // Expect a whitespace or line break.\n\n            if (!analyzer.IsBlankOrBreakOrZero())\n            {\n                throw new SyntaxErrorException(start, mark, \"While scanning a %TAG directive, did not find expected whitespace or line break.\");\n            }\n\n            return new TagDirective(handle, prefix, start, start);\n        }\n\n        /// <summary>\n        /// Scan a tag.\n        /// </summary>\n        private string ScanTagUri(string head, Mark start)\n        {\n            StringBuilder tag = new StringBuilder();\n            if (head != null && head.Length > 1)\n            {\n                tag.Append(head.Substring(1));\n            }\n\n            // Scan the tag.\n","sourceCodeStart":2080,"sourceCodeEnd":2116,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Scanner.cs#L2080-L2116","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n%TAG !e! tag:example.com,2000:extra\n// after\n%TAG !e! tag:example.com,2000:","handlingStrategy":"validation","validationCode":"// %TAG line must end after the prefix (whitespace/linebreak only)\nbool TagDirectiveLineTerminates(string line) =>\n    !line.StartsWith(\"%TAG\") ||\n    System.Text.RegularExpressions.Regex.IsMatch(line, \"^%TAG\\\\s+\\\\S+\\\\s+\\\\S+\\\\s*$\");","typeGuard":null,"tryCatchPattern":"try\n{\n    var obj = Deserializer.FromFile(path);\n}\ncatch (SyntaxErrorException ex)\n{\n    Log.Error(ex, \"Trailing garbage after %TAG prefix at line {Line}\", ex.Start.Line);\n    throw new YamlConfigException(\"%TAG prefix must be followed by whitespace or line break\", ex);\n}","preventionTips":["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"],"tags":["yaml","scanner","directive","tag"],"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"}