{"record":{"id":"3d5013dd353bf415","repo":"stride3d/stride","slug":"while-parsing-a-quoted-scalar-did-not-find-expected","errorCode":null,"errorMessage":"While parsing a quoted scalar, did not find expected hexdecimal number.","messagePattern":"While parsing a quoted scalar, did not find expected hexdecimal number\\.","errorType":"exception","errorClass":"SyntaxErrorException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Scanner.cs","lineNumber":1679,"sourceCode":"                                break;\n                        }\n\n                        Skip();\n                        Skip();\n\n                        // Consume an arbitrary escape code.\n\n                        if (codeLength > 0)\n                        {\n                            uint character = 0;\n\n                            // Scan the character value.\n\n                            for (int k = 0; k < codeLength; ++k)\n                            {\n                                if (!analyzer.IsHex(k))\n                                {\n                                    throw new SyntaxErrorException(start, mark, \"While parsing a quoted scalar, did not find expected hexdecimal number.\");\n                                }\n                                character = (uint) ((character << 4) + analyzer.AsHex(k));\n                            }\n\n                            // Check the value and write the character.\n\n                            if ((character >= 0xD800 && character <= 0xDFFF) || character > 0x10FFFF)\n                            {\n                                throw new SyntaxErrorException(start, mark, \"While parsing a quoted scalar, find invalid Unicode character escape code.\");\n                            }\n\n                            scanScalarValue.Append((char) character);\n\n                            // Advance the pointer.\n\n                            for (int k = 0; k < codeLength; ++k)\n                            {\n                                Skip();","sourceCodeStart":1661,"sourceCodeEnd":1697,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Scanner.cs#L1661-L1697","documentation":"Thrown by the YAML Scanner while scanning an escape sequence inside a single/double-quoted scalar (e.g. \\x, \\u, \\U). After the escape indicator the scanner expects exactly codeLength hexadecimal digits; if any position is not a hex digit the escape code is malformed and parsing cannot continue. This is a hard syntax error in the input document, not a runtime condition.","triggerScenarios":"Parsing a YAML stream (Scanner.Scan or higher-level Deserializer) that contains a quoted scalar with a Unicode escape sequence like \\x, \\u or \\U followed by fewer than the required hex digits or a non-hex character, e.g. \"\\xZZ\" or \"\\u12G4\".","commonSituations":"Hand-edited YAML config files where an escape was truncated by copy-paste; templates that interpolate into string literals leaving a lone backslash before non-hex text; content generated by tools that mix C/JSON escaping rules into YAML.","solutions":["Open the file at the reported line/column and complete the escape sequence with the correct number of hex digits (\\x needs 2, \\u needs 4, \\U needs 8).","Remove the backslash if the value was meant literally (YAML only needs escaping for control characters in double-quoted scalars).","Switch the scalar to a plain or single-quoted style so backslashes are treated literally and no escape parsing occurs.","Validate the YAML with a linter (yamllint or an online parser) before loading it in the application."],"exampleFix":"// before (bad input)\ntitle: \"Caf\\xZZ\"\n// after\ntitle: \"Caf\\u00e9\"","handlingStrategy":"validation","validationCode":"var re = new System.Text.RegularExpressions.Regex(\"\\\\\\\\x[0-9A-Fa-f]{2}|\\\\\\\\u[0-9A-Fa-f]{4}|\\\\\\\\U[0-9A-Fa-f]{8}\");\n// Scan the raw YAML text for quoted-scalar escapes before parsing:\nbool HasMalformedEscape(string yaml) =>\n    System.Text.RegularExpressions.Regex.IsMatch(yaml, \"\\\\\\\\(x[^0-9A-Fa-f]{2}|x[0-9A-Fa-f]{0,1}[^\\\\s\\\"][^\\\\s]|u[0-9A-Fa-f]{0,3}[^0-9A-Fa-f\\\\s]|U[0-9A-Fa-f]{0,7}[^0-9A-Fa-f\\\\s])\");","typeGuard":null,"tryCatchPattern":"try\n{\n    var obj = Deserializer.FromFile(path);\n}\ncatch (SyntaxErrorException ex)\n{\n    // ex shows start/mark with line & column of the bad escape\n    Log.Error(ex, \"Malformed hex escape in YAML at {Start}\", ex.Start);\n}","preventionTips":["Run yamllint or an online YAML parser in CI before loading config files","Prefer plain or single-quoted scalars unless escapes are genuinely needed","Avoid hand-writing \\x/\\u/\\U escapes; put literal UTF-8 characters in the file"],"tags":["yaml","scanner","escape-sequence","parsing"],"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"}