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

  1. Replace the '0' indicator with a positive digit (1-9), e.g. '|2' instead of '|0'.
  2. If you wanted auto-detected indentation, remove the digit entirely and just use '|' or '>'.
  3. Keep the digit adjacent to '|' or '>' in the header; chomping indicators +/- may follow, e.g. '|2-' or '|+2'.
  4. Fix generator code to clamp the computed indentation indicator to >= 1 or omit it when 0.
  5. 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

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


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)