{"record":{"id":"b964235b856764fe","repo":"stride3d/stride","slug":"while-parsing-a-quoted-scalar-find-unknown-escape-character","errorCode":null,"errorMessage":"While parsing a quoted scalar, find unknown escape character.","messagePattern":"While parsing a quoted scalar, find unknown escape character\\.","errorType":"exception","errorClass":"SyntaxErrorException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Scanner.cs","lineNumber":1659,"sourceCode":"                                break;\n\n                            case 'u':\n                                codeLength = 4;\n                                break;\n\n                            case 'U':\n                                codeLength = 8;\n                                break;\n\n                            default:\n                                char unescapedCharacter;\n                                if (simpleEscapeCodes.TryGetValue(escapeCharacter, out unescapedCharacter))\n                                {\n                                    scanScalarValue.Append(unescapedCharacter);\n                                }\n                                else\n                                {\n                                    throw new SyntaxErrorException(start, mark, \"While parsing a quoted scalar, find unknown escape character.\");\n                                }\n                                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))","sourceCodeStart":1641,"sourceCodeEnd":1677,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Scanner.cs#L1641-L1677","documentation":"Inside a double-quoted scalar, a backslash introduces an escape sequence that must be a recognized YAML escape (\\n, \\t, \\\\\", \\x41, \\u0041, etc.). ScanBlockScalar's quoted-scalar escape handling throws this SyntaxErrorException when the character after the backslash is not in the simpleEscapeCodes table and not a valid numeric escape.","triggerScenarios":"Double-quoted strings containing Windows paths or regexes with bare backslashes, e.g. \"path: \"C:\\Users\\test\"\" (\\U followed by unexpected chars) or \"pattern: \"\\d+\"\" — \\d is not a YAML escape. Thrown while scanning the escape sequence.","commonSituations":"Windows file paths pasted into double-quoted YAML values, regex patterns like \"\\d+\" or \"\\w\" written in double quotes, and shell scripts or JSON-ish habits ('\\/' is not special here) applied to YAML.","solutions":["Use forward slashes or double the backslashes in double-quoted strings: \"C:\\\\Users\\\\test\".","Switch the value to single quotes, where backslash is literal: 'C:\\Users\\test' and '\\d+' need no escaping.","Use only valid YAML escapes in double quotes: \\0 \\a \\b \\t \\n \\v \\f \\r \\e \\\" \\\\ \\N \\_ \\L \\P \\x.. \\u.... \\U.........","Escape regex backslashes explicitly: \"\\\\d+\" instead of \"\\d+\".","Check the reported column: the character right after the offending backslash identifies which escape is invalid."],"exampleFix":"// before (invalid \\U / \\d escapes)\npath: \"C:\\Users\\test\"\npattern: \"\\d+\"\n\n// after\npath: \"C:\\\\Users\\\\test\"\npattern: \"\\\\d+\"","handlingStrategy":"validation","validationCode":"static bool OnlyValidYamlEscapes(string yaml)\n{\n    var valid = new HashSet<char>(\"0abtvfre \\\"\\\\/N_LP\\t\\n\".ToCharArray());\n    int i = 0;\n    while ((i = yaml.IndexOf('\\\\', i)) >= 0)\n    {\n        char next = i + 1 < yaml.Length ? yaml[i + 1] : '\\0';\n        if (next != 'x' && next != 'u' && next != 'U' && !valid.Contains(next)) return false;\n        i += 2;\n    }\n    return true;\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var obj = deserializer.Deserialize<T>(input);\n}\ncatch (YamlException ex)\n{\n    throw new FormatException($\"Unknown escape sequence near {ex.Start.Line}:{ex.Start.Column}: {ex.Message}\", ex);\n}","preventionTips":["Prefer single quotes for values containing backslashes (paths, regexes)","In double quotes, always double backslashes: \"\\\\d+\", \"C:\\\\\\\\Users\"","Remember YAML escapes: only \\\\0 \\\\a \\\\b \\\\t \\\\n \\\\v \\\\f \\\\r \\\\e \\\\\" \\\\/ \\\\N \\\\_ \\\\L \\\\P \\\\x \\\\u \\\\U are valid","Test config snippets with the same parser version used in production before deploying"],"tags":["yaml","parser","escaping","quotes"],"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-23T08:17:48.524Z"}