{"record":{"id":"3c96d93c303c44d6","repo":"stride3d/stride","slug":"while-scanning-a-tag-directive-did-not-find-expected","errorCode":null,"errorMessage":"While scanning a %TAG directive, did not find expected whitespace.","messagePattern":"While scanning a %TAG directive, did not find expected whitespace\\.","errorType":"exception","errorClass":"SyntaxErrorException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Scanner.cs","lineNumber":2085,"sourceCode":"        /// Scan the value of a TAG-DIRECTIVE token.\n        ///\n        /// Scope:\n        ///      %TAG    !yaml!  tag:yaml.org,2002:  \\n\n        ///          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n        /// </summary>\n        private Token ScanTagDirectiveValue(Mark start)\n        {\n            SkipWhitespaces();\n\n            // Scan a handle.\n\n            string handle = ScanTagHandle(true, start);\n\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","sourceCodeStart":2067,"sourceCodeEnd":2103,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Scanner.cs#L2067-L2103","documentation":"Thrown by the YAML Scanner when, after scanning the handle of a %TAG directive, the next character is not a whitespace. A %TAG directive must separate its handle and prefix with whitespace, e.g. '%TAG ! tag:example.com,2000:'.","triggerScenarios":"Parsing YAML with a %TAG directive missing the space between handle and prefix, e.g. '%TAG!!foo:' or '%TAG!e!tag:example.com'.","commonSituations":"Minified or hand-compressed YAML where spaces were stripped; typos merging the handle with the prefix; generated tag directives from buggy writers.","solutions":["Insert a space between the tag handle and the tag URI prefix: '%TAG !e! tag:example.com,2000:'.","Remove the %TAG directive if tag shorthand is not needed and use full tag URIs inline.","Check for missing spaces caused by aggressive whitespace stripping in a build/minify step.","Validate the file with yamllint or an online YAML parser before deployment."],"exampleFix":"// before\n%TAG!e!tag:example.com,2000:\n---\n// after\n%TAG !e! tag:example.com,2000:\n---","handlingStrategy":"validation","validationCode":"bool IsValidTagDirective(string line) =>\n    !line.StartsWith(\"%TAG\") ||\n    System.Text.RegularExpressions.Regex.IsMatch(line, \"^%TAG\\\\s+!?[!A-Za-z0-9-]*!\\\\s+\\\\S+\");","typeGuard":null,"tryCatchPattern":"try\n{\n    var obj = Deserializer.FromText(yaml);\n}\ncatch (SyntaxErrorException ex)\n{\n    Log.Error(ex, \"Missing whitespace in %TAG directive at line {Line}\", ex.Start.Line);\n    throw;\n}","preventionTips":["Keep a space between handle and prefix: '%TAG !e! tag:example.com,2000:'","Avoid whitespace-stripping/minification steps on YAML files","Validate tag directives with a reference parser before deployment"],"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"}