{"record":{"id":"be06a6d347c126e1","repo":"stride3d/stride","slug":"while-scanning-a-quoted-scalar-find-unexpected-document","errorCode":null,"errorMessage":"While scanning a quoted scalar, find unexpected document indicator.","messagePattern":"While scanning a quoted scalar, find unexpected document indicator\\.","errorType":"exception","errorClass":"SyntaxErrorException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Scanner.cs","lineNumber":1586,"sourceCode":"            // Eat the left quote.\n\n            Mark start = mark;\n            Mark end = mark;\n\n            Skip();\n\n            // Consume the content of the quoted scalar.\n            scanScalarValue.Clear();\n            scanScalarWhitespaces.Clear();\n            scanScalarLeadingBreak.Clear();\n            scanScalarTrailingBreaks.Clear();\n            for (;;)\n            {\n                // Check that there are no document indicators at the beginning of the line.\n\n                if (IsDocumentIndicator())\n                {\n                    throw new SyntaxErrorException(start, mark, \"While scanning a quoted scalar, find unexpected document indicator.\");\n                }\n\n                // Check for EOF.\n\n                if (analyzer.IsZero())\n                {\n                    throw new SyntaxErrorException(start, mark, \"While scanning a quoted scalar, find unexpected end of stream.\");\n                }\n\n                // Consume non-blank characters.\n\n                bool hasLeadingBlanks = false;\n\n                while (!analyzer.IsBlankOrBreakOrZero())\n                {\n                    // Check for an escaped single quote.\n\n                    if (isSingleQuoted && analyzer.Check('\\'', 0) && analyzer.Check('\\'', 1))","sourceCodeStart":1568,"sourceCodeEnd":1604,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Scanner.cs#L1568-L1604","documentation":"While scanning a single- or double-quoted scalar, the Scanner checks at the start of each line whether a YAML document indicator (--- or ...) begins there. A quoted scalar must not span a document boundary, so encountering '---' or '...' at line start inside an unterminated quote throws this SyntaxErrorException.","triggerScenarios":"An unclosed quote earlier in the document causes subsequent '---'/'...' document markers to be consumed as part of the quoted scalar; e.g. \"title: 'unclosed\\n---\\nnext: doc\". Thrown during tokenization of multi-document streams with an unbalanced quote in an earlier document.","commonSituations":"Multi-document YAML files (--- separated) where a quote in one document was never closed, string content containing three dashes at line start without proper quoting, and concatenating documents that lost a closing quote.","solutions":["Find and close the unterminated quote that precedes the '---'/'...' line (the scanner's start Mark points at the quoted scalar's beginning).","Ensure document separators '---'/'...' appear only at line start outside any quoted scalar.","If the content legitimately starts a line with '---', use a block scalar (| or >) instead of a quoted scalar.","Quote content containing dashes with double quotes and keep the quote on one line, or escape appropriately.","Split multi-document streams and parse each document separately to isolate the offending quote."],"exampleFix":"// before (unclosed quote swallows the document marker)\ntitle: 'unclosed\n---\nnext: value\n\n// after\ntitle: 'closed'\n---\nnext: value","handlingStrategy":"try-catch","validationCode":"static bool QuotesLookBalanced(string yaml)\n{\n    int singles = 0, doubles = 0;\n    foreach (char c in yaml)\n    {\n        if (c == '\\'') singles ^= 1;\n        else if (c == '\"') doubles ^= 1;\n    }\n    return singles == 0 && doubles == 0; // rough check, ignores escapes\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    yamlStream.Load(reader);\n}\ncatch (YamlException ex)\n{\n    throw new FormatException($\"Unterminated quote (ran into a document marker) starting near {ex.Start.Line}:{ex.Start.Column}\", ex);\n}","preventionTips":["Close every quote in each document before the --- separator","Use block scalars (|, >) for content containing lines that start with dashes","Parse multi-document streams one document at a time to localize failures","Count quotes per document as a cheap sanity check before loading"],"tags":["yaml","parser","quotes","documents"],"backgroundTag":"yaml-parse-error","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}