{"record":{"id":"4625544786ebded3","repo":"stride3d/stride","slug":"while-scanning-a-directive-find-unexpected-non-alphabetical","errorCode":null,"errorMessage":"While scanning a directive, find unexpected non-alphabetical character.","messagePattern":"While scanning a directive, find unexpected non-alphabetical character\\.","errorType":"exception","errorClass":"SyntaxErrorException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Scanner.cs","lineNumber":2019,"sourceCode":"            // Consume the directive name.\n\n            while (analyzer.IsAlpha())\n            {\n                name.Append(ReadCurrentCharacter());\n            }\n\n            // Check if the name is empty.\n\n            if (name.Length == 0)\n            {\n                throw new SyntaxErrorException(start, mark, \"While scanning a directive, could not find expected directive name.\");\n            }\n\n            // Check for an blank character after the name.\n\n            if (!analyzer.IsBlankOrBreakOrZero())\n            {\n                throw new SyntaxErrorException(start, mark, \"While scanning a directive, find unexpected non-alphabetical character.\");\n            }\n\n            return name.ToString();\n        }\n\n        private void SkipWhitespaces()\n        {\n            // Eat whitespaces.\n\n            while (analyzer.IsBlank())\n            {\n                Skip();\n            }\n        }\n\n        /// <summary>\n        /// Scan the value of VERSION-DIRECTIVE.\n        ///","sourceCodeStart":2001,"sourceCodeEnd":2037,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Scanner.cs#L2001-L2037","documentation":"Thrown by the YAML Scanner when a directive name contains a character outside the allowed alphanumeric set, or a non-blank character immediately follows the directive name. Directive names (YAML, TAG) may contain only alphanumerics and must be followed by whitespace or a line break.","triggerScenarios":"Parsing YAML with a malformed directive such as '%YAML-1.1' (hyphen attached to the name) or '%FOO!' where a punctuation character directly follows the name without whitespace.","commonSituations":"Typos like '%YAML1.1' or '%yaml:1.2'; custom directives invented by users that YAML does not allow; copy-paste corruption introducing punctuation into directive lines.","solutions":["Correct the directive spelling and syntax, e.g. '%YAML 1.1' with a space before the version.","Remove unsupported directives — only %YAML and %TAG are defined.","If the line is not meant to be a directive, remove the leading '%' or quote the line as content.","Escape or strip '%' lines during preprocessing if input comes from a system that uses '%' for other syntax."],"exampleFix":"// before\n%YAML-1.1\n---\n// after\n%YAML 1.1\n---","handlingStrategy":"validation","validationCode":"bool IsValidDirectiveLine(string line) =>\n    line.StartsWith(\"%\") &&\n    System.Text.RegularExpressions.Regex.IsMatch(line, \"^%[A-Za-z0-9]+[ \\\\t\\\\r\\\\n]\");","typeGuard":null,"tryCatchPattern":"try\n{\n    var obj = Deserializer.FromText(yaml);\n}\ncatch (SyntaxErrorException ex)\n{\n    Log.Error(ex, \"Non-alphabetical character in directive at line {Line}\", ex.Start.Line);\n    throw;\n}","preventionTips":["Only use the standard directives '%YAML 1.1' and '%TAG handle prefix'","Never attach punctuation ('-', ':', '!') directly to a directive name","Strip or quote '%' lines coming from foreign syntaxes (LaTeX comments, Makefiles)"],"tags":["yaml","scanner","directive","syntax"],"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"}