stride3d/stride · error · SyntaxErrorException
While scanning a plain scalar, find unexpected ':'.
Error message
While scanning a plain scalar, find unexpected ':'.
What it means
Thrown by the YAML Scanner while scanning a plain (unquoted) scalar when a ':' appears in a position where it would be ambiguous or illegal — specifically inside flow context ({}, []) when the colon is not followed by a blank/break, or a colon elsewhere in a spot that terminates the scalar incorrectly. YAML only allows ':' in plain scalars under strict conditions, and this input violates them.
Solutions
- Quote the offending scalar with double or single quotes so ':' is allowed anywhere inside it.
- Add a space after the colon if it was meant as a mapping separator, e.g. {a: b} instead of {a:b}.
- Rewrite the flow collection as block-style mappings, which have more lenient colon handling.
- Validate the document with a YAML parser before feeding it to the application.
Example fix
// before urls: [http://example.com, http://other.org] // after urls: ["http://example.com", "http://other.org"]
Defensive patterns
Strategy: try-catch
Validate before calling
// Detect 'x:y' inside flow context before parsing
bool HasColonInFlowScalar(string yaml) =>
System.Text.RegularExpressions.Regex.IsMatch(yaml, "\\{[^}]*[a-zA-Z0-9]:[^\\s}]"); Try / catch
try
{
var obj = new Deserializer().Deserialize<ObjectT>(yamlReader);
}
catch (SyntaxErrorException ex)
{
Log.Error(ex, "Unexpected ':' in plain scalar at line {Line}, col {Col}", ex.Start.Line, ex.Start.Column);
throw;
} Prevention
- Always quote scalars containing ':' (URLs, times, key:value strings) inside flow collections
- Use block-style YAML rather than JSON-like flow style when values contain colons
- Round-trip YAML through the library when generating it instead of string concatenation
When it happens
Trigger: Parsing YAML containing a plain scalar with 'key:value' (no space after colon) inside a flow collection, e.g. {a:b: c}, or any plain scalar where a ':' is followed by a non-space in flow context.
Common situations: Users writing JSON-ish '{url:http://example.com}' in YAML; URLs containing ':' inside flow sequences without quoting; values copied from JSON that rely on JSON's looser colon rules.
Related errors
- Block sequence entries are not allowed in this context.
- Mapping keys are not allowed in this context.
- Mapping values are not allowed in this context.
- While parsing a quoted scalar, did not find expected…
- While parsing a quoted scalar, find invalid Unicode…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/10aefc288ce2fae3.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Scanner.cs:1846
{
break;
}
// Check for a comment.
if (analyzer.Check('#'))
{
break;
}
// Consume non-blank characters.
while (!analyzer.IsBlankOrBreakOrZero())
{
// Check for 'x:x' in the flow context. TODO: Fix the test "spec-08-13".
if (flowLevel > 0 && analyzer.Check(':') && !analyzer.IsBlankOrBreakOrZero(1))
{
throw new SyntaxErrorException(start, mark, "While scanning a plain scalar, find unexpected ':'.");
}
// Check for indicators that may end a plain scalar.
if ((analyzer.Check(':') && analyzer.IsBlankOrBreakOrZero(1)) || (flowLevel > 0 && analyzer.Check(",:?[]{}")))
{
break;
}
// Check if we need to join whitespaces and breaks.
if (hasLeadingBlanks || whitespaces.Length > 0)
{
if (hasLeadingBlanks)
{
// Do we need to fold line breaks?
if (StartsWith(leadingBreak, '\n'))View on GitHub (pinned to 96fad776d2)