stride3d/stride · error · SyntaxErrorException
While scanning a block scalar, find a tab character where…
Error message
While scanning a block scalar, find a tab character where an intendation space is expected.
What it means
Inside a block scalar's body, indentation must consist of spaces only. ScanBlockScalar throws this SyntaxErrorException when it detects a tab character on a line whose column is before the required indentation (or while indentation is still 0), because tabs cannot count as indentation in YAML block scalars.
Solutions
- Replace leading tabs with spaces in all lines of the block scalar.
- Configure your editor to insert spaces for indentation in YAML files (editorconfig: indent_style = space).
- Fix generator/serializer code to pad with spaces, e.g. new string(' ', indent) instead of '\t'.
- Re-encode files: run expand -t 2 (or similar) over the YAML to convert tabs to spaces.
- Add a pre-commit or CI check rejecting tab characters at line starts in YAML files.
Example fix
// before (tab indentation inside block scalar) text: | line one // after (spaces) text: | line one
Defensive patterns
Strategy: validation
Validate before calling
static bool NoLeadingTabs(string yamlContent) =>
!yamlContent.Split('\n').Any(line => line.Length > 0 && (line[0] == '\t' || line.TrimEnd().StartsWith("\t"))); Try / catch
try
{
var obj = deserializer.Deserialize<T>(input);
}
catch (YamlException ex)
{
throw new FormatException($"Tab used for indentation at {ex.Start.Line}:{ex.Start.Column} — replace tabs with spaces", ex);
} Prevention
- Use spaces only for YAML indentation; set indent_style=space in .editorconfig
- Run 'expand' or an equivalent to normalize tabs before parsing
- Never emit '\\t' from generators for block scalar indentation
- Add a CI check rejecting tab characters at line starts in YAML files
When it happens
Trigger: A multi-line block scalar whose continuation lines are indented with tab characters instead of spaces, e.g. 'text: |\n\tline'. Any parse of such content throws while scanning the block scalar body.
Common situations: Editors configured with tab indentation saving YAML files, code generators emitting '\t' prefixes for multi-line strings, and paste operations converting leading spaces to tabs.
Related errors
- Did not find expected
- Did not find expected <stream-start>.
- Expected ' ', got ' ' (at line , character ).
- The length must be positive.
- While parsing a block collection, did not find expected '-'…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/772c031748015c89.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Scanner.cs:1518
for (;;)
{
// Eat the intendation spaces.
while ((currentIndent == 0 || mark.Column < currentIndent) && analyzer.IsSpace())
{
Skip();
}
if (mark.Column > maxIndent)
{
maxIndent = mark.Column;
}
// Check for a tab character messing the intendation.
if ((currentIndent == 0 || mark.Column < currentIndent) && analyzer.IsTab())
{
throw new SyntaxErrorException(start, mark, "While scanning a block scalar, find a tab character where an intendation space is expected.");
}
// Have we find a non-empty line?
if (!analyzer.IsBreak())
{
break;
}
// Consume the line break.
ReadLine(breaks);
end = mark;
}
// Determine the indentation level if needed.
View on GitHub (pinned to 96fad776d2)