{"record":{"id":"f353f30d430276fd","repo":"stride3d/stride","slug":"while-scanning-a-yaml-directive-did-not-find-expected-digit","errorCode":null,"errorMessage":"While scanning a %YAML directive, did not find expected digit or '.' character.","messagePattern":"While scanning a %YAML directive, did not find expected digit or '\\.' character\\.","errorType":"exception","errorClass":"SyntaxErrorException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Scanner.cs","lineNumber":2054,"sourceCode":"        /// Scan the value of VERSION-DIRECTIVE.\n        ///\n        /// Scope:\n        ///      %YAML   1.1     # a comment \\n\n        ///           ^^^^^^\n        /// </summary>\n        private Token ScanVersionDirectiveValue(Mark start)\n        {\n            SkipWhitespaces();\n\n            // Consume the major version number.\n\n            int major = ScanVersionDirectiveNumber(start);\n\n            // Eat '.'.\n\n            if (!analyzer.Check('.'))\n            {\n                throw new SyntaxErrorException(start, mark, \"While scanning a %YAML directive, did not find expected digit or '.' character.\");\n            }\n\n            Skip();\n\n            // Consume the minor version number.\n\n            int minor = ScanVersionDirectiveNumber(start);\n\n            return new VersionDirective(new Version(major, minor), start, start);\n        }\n\n        /// <summary>\n        /// Scan the value of a TAG-DIRECTIVE token.\n        ///\n        /// Scope:\n        ///      %TAG    !yaml!  tag:yaml.org,2002:  \\n\n        ///          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n        /// </summary>","sourceCodeStart":2036,"sourceCodeEnd":2072,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Scanner.cs#L2036-L2072","documentation":"Thrown by the YAML Scanner while parsing the version number of a %YAML directive. After the major version digits the scanner requires a '.' before the minor version; if the next character is not a '.' (or a digit was missing) the directive is malformed.","triggerScenarios":"Parsing YAML whose %YAML directive has a malformed version, e.g. '%YAML 1' (no dot/minor), '%YAML x.y' (non-digit major), or '%YAML 1.1.1' style corruption where the expected '.' is absent.","commonSituations":"Hand-edited version directives; tools writing '%YAML 1' instead of '%YAML 1.1'; truncated files cut off mid-directive.","solutions":["Fix the directive to full 'major.minor' form: '%YAML 1.1' or '%YAML 1.2'.","Remove the %YAML directive entirely if version declaration is unnecessary (the parser defaults to 1.1).","Regenerate the file from its source/template if it was truncated.","Validate with a YAML parser before loading to catch directive typos early."],"exampleFix":"// before\n%YAML 1\n---\n// after\n%YAML 1.1\n---","handlingStrategy":"validation","validationCode":"bool IsValidYamlVersionDirective(string line) =>\n    !line.StartsWith(\"%YAML\") ||\n    System.Text.RegularExpressions.Regex.IsMatch(line, \"^%YAML \\\\d+\\\\.\\\\d+\\\\s*$\");","typeGuard":null,"tryCatchPattern":"try\n{\n    var obj = Deserializer.FromFile(path);\n}\ncatch (SyntaxErrorException ex)\n{\n    Log.Error(ex, \"Bad %YAML version at line {Line}\", ex.Start.Line);\n    throw new YamlConfigException(\"%YAML directive must be 'major.minor'\", ex);\n}","preventionTips":["Always write the full version: '%YAML 1.1' or '%YAML 1.2'","Omit the %YAML directive when the default version is acceptable","Lint YAML files in CI to catch directive typos"],"tags":["yaml","scanner","directive","version"],"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"}