stride3d/stride · error · SyntaxErrorException

While scanning a quoted scalar, find unexpected end of…

Error message

While scanning a quoted scalar, find unexpected end of stream.

What it means

A quoted scalar must be terminated by its matching closing quote before the input ends. If ScanBlockScalar's quoted-scalar loop reaches EOF (the character analyzer reports zero/end of stream) without seeing the closing quote, this SyntaxErrorException is thrown.

Solutions

  1. Add the missing closing quote of the same kind (' or ") at the end of the scalar value.
  2. Check the file was not truncated — compare byte/line counts against the source and re-download if needed.
  3. Look at the line/column in the exception Mark: the scalar started there; inspect from that point to EOF for the missing quote.
  4. Enable editor bracket/quote auto-closing and re-check modified strings after edits.
  5. Parse YAML in CI before deploy so truncated configs fail fast with a clear message.

Example fix

// before (missing closing quote)
name: 'unclosed value

// after
name: 'unclosed value'
Defensive patterns

Strategy: try-catch

Validate before calling

static bool NotTruncated(string yaml, string expectedEndMarker = null) =>
    yaml.Length > 0 && (expectedEndMarker == null || yaml.TrimEnd().EndsWith(expectedEndMarker));

Try / catch

try
{
    var obj = deserializer.Deserialize<T>(input);
}
catch (YamlException ex)
{
    if (ex.Message.Contains("end of stream"))
        throw new FormatException($"YAML appears truncated: quote opened at {ex.Start.Line}:{ex.Start.Column} never closed", ex);
    throw;
}

Prevention

When it happens

Trigger: A single- or double-quoted value missing its closing quote at end of file, e.g. "name: 'value" with nothing after, or a file truncated mid-string. Thrown while tokenizing quoted scalars that run to end of input.

Common situations: Files truncated by failed uploads/downloads or disk-full writes, editors or string templates that dropped a trailing quote, and manual edits that removed a closing quote.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/5dcb96f5d0ce00d8. Report an issue: GitHub.

Appendix: source

Thrown at sources/core/Stride.Core.Yaml/Scanner.cs:1593

            // Consume the content of the quoted scalar.
            scanScalarValue.Clear();
            scanScalarWhitespaces.Clear();
            scanScalarLeadingBreak.Clear();
            scanScalarTrailingBreaks.Clear();
            for (;;)
            {
                // Check that there are no document indicators at the beginning of the line.

                if (IsDocumentIndicator())
                {
                    throw new SyntaxErrorException(start, mark, "While scanning a quoted scalar, find unexpected document indicator.");
                }

                // Check for EOF.

                if (analyzer.IsZero())
                {
                    throw new SyntaxErrorException(start, mark, "While scanning a quoted scalar, find unexpected end of stream.");
                }

                // Consume non-blank characters.

                bool hasLeadingBlanks = false;

                while (!analyzer.IsBlankOrBreakOrZero())
                {
                    // Check for an escaped single quote.

                    if (isSingleQuoted && analyzer.Check('\'', 0) && analyzer.Check('\'', 1))
                    {
                        scanScalarValue.Append('\'');
                        Skip();
                        Skip();
                    }

                    // Check for the right quote.

View on GitHub (pinned to 96fad776d2)