stride3d/stride · error · SyntaxErrorException
While scanning a simple key, could not find expected ':'.
Error message
While scanning a simple key, could not find expected ':'.
What it means
The scanner saw a token that looked like a potential simple key (a scalar that could precede ':') but the ':' never arrived before a line break or the 1024-character limit. When that potential key is required (a mapping key in block context must have a colon), scanning fails with this SyntaxErrorException.
Solutions
- Add the missing ':' after the key on the reported line
- Ensure the key and its ':' are on the same line
- If the scalar is a value not a key, fix indentation so it is not treated as a mapping key
- Quote long or multi-line strings and use block scalars (| or >) for values
Example fix
// before config: name value: 1 // after config: name: myapp value: 1
Defensive patterns
Strategy: try-catch
Validate before calling
// Ensure every non-comment, non-list line in block context ends with ':' or contains ': '
foreach (var line in yamlText.Split('\n')) { var t = line.Trim(); if (t.Length>0 && !t.StartsWith("#") && !t.StartsWith("-") && !t.Contains(':')) throw new FormatException("Line lacks key/value colon: " + line); } Try / catch
catch (SyntaxErrorException ex) { throw new ConfigFormatException($"Missing ':' near {ex.Start.Line}:{ex.Start.Column}"); } Prevention
- Never leave a bare key without a colon in a mapping
- Keep key/value on a single line
- Use block scalars (| or >) for multi-line strings
- Lint YAML in CI before deployment
When it happens
Trigger: A block-context mapping line where the key scalar is followed by a line break instead of ':', e.g. 'key' alone on a line inside a block mapping, or an extremely long scalar (>1024 chars) with no colon.
Common situations: Forgot to type ':' after a key in a config file, a key wrapped onto the next line by copy/paste, or multiline plain scalars accidentally interpreted as keys.
Related errors
- While scanning a directive, find unexpected…
- While parsing a block mapping, did not find expected key.
- While parsing a flow sequence, did not find expected ',' or…
- While parsing a flow mapping, did not find expected ',' or…
- While scanning for the next token, find character that…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/b46e088b717f6984.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Scanner.cs:273
private void StaleSimpleKeys()
{
// Check for a potential simple key for each flow level.
foreach (var key in simpleKeys)
{
// The specification requires that a simple key
// - is limited to a single line,
// - is shorter than 1024 characters.
if (key.IsPossible && (key.Mark.Line < mark.Line || key.Mark.Index + 1024 < mark.Index))
{
// Check if the potential simple key to be removed is required.
if (key.IsRequired)
{
throw new SyntaxErrorException(mark, mark, "While scanning a simple key, could not find expected ':'.");
}
key.IsPossible = false;
}
}
}
private void FetchNextToken()
{
// Check if we just started scanning. Fetch STREAM-START then.
if (!streamStartProduced)
{
FetchStreamStart();
return;
}
// Eat whitespaces and comments until we reach the next token.View on GitHub (pinned to 96fad776d2)