stride3d/stride · error · SyntaxErrorException
While scanning a block scalar, find an intendation…
Error message
While scanning a block scalar, find an intendation indicator equal to 0.
What it means
For block scalars (| and >), an explicit indentation indicator is a single digit following the indicator (e.g. '|2'). YAML forbids 0 as that digit because zero indentation is meaningless, so ScanBlockScalar throws this SyntaxErrorException when it reads a '0' as the indentation indicator in the header (digit-before-chomping order).
Solutions
- Replace the '0' indicator with a positive digit (1-9), e.g. '|2' instead of '|0'.
- If you wanted auto-detected indentation, remove the digit entirely and just use '|' or '>'.
- Keep the digit adjacent to '|' or '>' in the header; chomping indicators +/- may follow, e.g. '|2-' or '|+2'.
- Fix generator code to clamp the computed indentation indicator to >= 1 or omit it when 0.
- Lint the YAML before loading to catch invalid block scalar headers.
Example fix
// before (invalid zero indentation indicator) text: |0 line // after text: |2 line
Defensive patterns
Strategy: try-catch
Validate before calling
static bool HasNoZeroIndentIndicator(string yaml) =>
!System.Text.RegularExpressions.Regex.IsMatch(yaml, @"[|>][0-9]|[|>][+-]?0"); Try / catch
try
{
var obj = deserializer.Deserialize<T>(input);
}
catch (YamlException ex)
{
throw new FormatException($"Invalid block scalar header at {ex.Start.Line}:{ex.Start.Column}: {ex.Message}", ex);
} Prevention
- Indentation indicators must be 1-9; omit the digit to auto-detect
- If generating headers, clamp computed indent to >= 1 or drop the indicator at 0
- Remember order: |/> then optional digit and/or +/- chomping (either order)
- Grep for '|0' and '>0' patterns in YAML assets as a cheap CI check
When it happens
Trigger: A block scalar header like '|0', '>0', '|0-' or '|+0' (digit appearing before the chomping indicator in the source). Any parse of a document containing such a header throws when the scanner processes the block scalar.
Common situations: Misunderstanding of the indentation indicator syntax (people write '|0' thinking it means 'auto-detect'), programmatic generation of block scalars with a computed indent of 0, and hand-edited multiline strings in configs.
Related errors
- While scanning a block scalar, did not find expected…
- Did not find expected
- Did not find expected <stream-start>.
- Expected ' ', got ' ' (at line , character ).
- The length must be positive.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/7b59a67de36a1cbe.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Scanner.cs:1342
// Check for a chomping indicator.
if (analyzer.Check("+-"))
{
// Set the chomping method and eat the indicator.
chomping = analyzer.Check('+') ? +1 : -1;
Skip();
// Check for an indentation indicator.
if (analyzer.IsDigit())
{
// Check that the intendation is greater than 0.
if (analyzer.Check('0'))
{
throw new SyntaxErrorException(start, mark, "While scanning a block scalar, find an intendation indicator equal to 0.");
}
// Get the intendation level and eat the indicator.
increment = analyzer.AsDigit();
Skip();
}
}
// Do the same as above, but in the opposite order.
else if (analyzer.IsDigit())
{
if (analyzer.Check('0'))
{
throw new SyntaxErrorException(start, mark, "While scanning a block scalar, find an intendation indicator equal to 0.");
}View on GitHub (pinned to 96fad776d2)