stride3d/stride · error · SyntaxErrorException
While parsing a quoted scalar, find unknown escape…
Error message
While parsing a quoted scalar, find unknown escape character.
What it means
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.
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.
Example fix
// before (invalid \U / \d escapes) path: "C:\Users\test" pattern: "\d+" // after path: "C:\\Users\\test" pattern: "\\d+"
Defensive patterns
Strategy: validation
Validate before calling
static bool OnlyValidYamlEscapes(string yaml)
{
var valid = new HashSet<char>("0abtvfre \"\\/N_LP\t\n".ToCharArray());
int i = 0;
while ((i = yaml.IndexOf('\\', i)) >= 0)
{
char next = i + 1 < yaml.Length ? yaml[i + 1] : '\0';
if (next != 'x' && next != 'u' && next != 'U' && !valid.Contains(next)) return false;
i += 2;
}
return true;
} Try / catch
try
{
var obj = deserializer.Deserialize<T>(input);
}
catch (YamlException ex)
{
throw new FormatException($"Unknown escape sequence near {ex.Start.Line}:{ex.Start.Column}: {ex.Message}", ex);
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- While scanning a quoted scalar, find unexpected document…
- While scanning a quoted scalar, find unexpected end of…
- Did not find expected
- Did not find expected <stream-start>.
- Expected ' ', got ' ' (at line , character ).
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/b964235b856764fe.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Scanner.cs:1659
break;
case 'u':
codeLength = 4;
break;
case 'U':
codeLength = 8;
break;
default:
char unescapedCharacter;
if (simpleEscapeCodes.TryGetValue(escapeCharacter, out unescapedCharacter))
{
scanScalarValue.Append(unescapedCharacter);
}
else
{
throw new SyntaxErrorException(start, mark, "While parsing a quoted scalar, find unknown escape character.");
}
break;
}
Skip();
Skip();
// Consume an arbitrary escape code.
if (codeLength > 0)
{
uint character = 0;
// Scan the character value.
for (int k = 0; k < codeLength; ++k)
{
if (!analyzer.IsHex(k))View on GitHub (pinned to 96fad776d2)