stride3d/stride · error · SemanticErrorException
While parsing a block collection, did not find expected '-'…
Error message
While parsing a block collection, did not find expected '-' indicator.
What it means
In the block-sequence state, the parser expects each entry to begin with a BLOCK-ENTRY token ('-'). When it encounters any other token, ParseBlockSequenceEntry throws SemanticErrorException at that token's span, indicating the sequence is malformed at that point.
Solutions
- Ensure every item at the sequence indentation level starts with '-'
- Fix inconsistent indentation so sequence items align and are more indented than the parent key
- Replace tabs with spaces — YAML forbids tabs for indentation
Example fix
// before list: - a b: c // after list: - a other: c
Defensive patterns
Strategy: try-catch
Validate before calling
// reject tabs and flag items at sequence level lacking '-'
if (text.Contains('\t')) throw new InvalidDataException("Tabs are not allowed in YAML indentation"); Try / catch
try { stream.Load(reader); } catch (SemanticErrorException ex) when (ex.Message.Contains("'-' indicator")) { throw new YamlConfigException($"Malformed block sequence near {ex.Start}", ex); } Prevention
- Use spaces, never tabs, for YAML indentation
- Keep '-' items aligned at the same column
- Lint YAML before loading user-edited files
When it happens
Trigger: Mixing indentation and '-' incorrectly, e.g. a non-'-' token at the sequence's indentation level: "list:\n- a\nb: c" where 'b: c' appears at sequence-entry column; or inconsistent indentation of '-' items.
Common situations: Hand-edited lists where an item lost its leading '- ', tab/space indentation mismatches, converting between flow and block styles partially.
Related errors
- Did not find expected <stream-start>.
- Did not find expected
- While parsing a node, did not find expected node content.
- Expected ' ', got ' ' (at line , character ).
- While parsing a node, find undefined tag handle.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/16a8765645922dbb.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Parser.cs:632
else
{
state = ParserState.YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE;
return ProcessEmptyScalar(mark);
}
}
else if (GetCurrentToken() is BlockEnd)
{
state = states.Pop();
Event evt = new Events.SequenceEnd(GetCurrentToken().Start, GetCurrentToken().End);
Skip();
return evt;
}
else
{
var current = GetCurrentToken();
throw new SemanticErrorException(current.Start, current.End, "While parsing a block collection, did not find expected '-' indicator.");
}
}
/// <summary>
/// Parse the productions:
/// indentless_sequence ::= (BLOCK-ENTRY block_node?)+
/// *********** *
/// </summary>
private Event ParseIndentlessSequenceEntry()
{
if (GetCurrentToken() is BlockEntry)
{
Mark mark = GetCurrentToken().End;
Skip();
if (!(GetCurrentToken() is BlockEntry || GetCurrentToken() is Key || GetCurrentToken() is Value || GetCurrentToken() is BlockEnd))
{
states.Push(ParserState.YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE);View on GitHub (pinned to 96fad776d2)