{"record":{"id":"8871a88db47c5847","repo":"stride3d/stride","slug":"while-scanning-a-block-scalar-did-not-find-expected-comment","errorCode":null,"errorMessage":"While scanning a block scalar, did not find expected comment or line break.","messagePattern":"While scanning a block scalar, did not find expected comment or line break\\.","errorType":"exception","errorClass":"SyntaxErrorException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Scanner.cs","lineNumber":1393,"sourceCode":"\n            while (analyzer.IsBlank())\n            {\n                Skip();\n            }\n\n            if (analyzer.Check('#'))\n            {\n                while (!analyzer.IsBreakOrZero())\n                {\n                    Skip();\n                }\n            }\n\n            // Check if we are at the end of the line.\n\n            if (!analyzer.IsBreakOrZero())\n            {\n                throw new SyntaxErrorException(start, mark, \"While scanning a block scalar, did not find expected comment or line break.\");\n            }\n\n            // Eat a line break.\n\n            if (analyzer.IsBreak())\n            {\n                SkipLine();\n            }\n\n            Mark end = mark;\n\n            // Set the intendation level if it was specified.\n\n            if (increment != 0)\n            {\n                currentIndent = indent >= 0 ? indent + increment : increment;\n            }\n","sourceCodeStart":1375,"sourceCodeEnd":1411,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Scanner.cs#L1375-L1411","documentation":"A block scalar's first line may only contain the header (|/> with optional indicators) followed by optional spaces and a comment, then a line break. If ScanBlockScalar finds any other non-break, non-comment character after the header (or trailing content after the header comment), it throws this SyntaxErrorException.","triggerScenarios":"Content on the same line as the block scalar header, e.g. 'text: | extra content' or '|#comment junk' where text follows the comment, or a missing line break right after '|' or '>'. Thrown while tokenizing the block scalar header.","commonSituations":"Appending notes or defaults after '|' in hand-edited configs, template engines leaving placeholder text on the header line, and copy-paste merging the header line with the first content line.","solutions":["Put the block content on the lines following the header: 'text: |' then newline then content.","Remove any stray text after '|' or '>' on the header line; only an optional comment (starting with #) is allowed before the line break.","Ensure a '#' comment after the header is separated by at least one space and nothing follows the comment.","Check for lost newlines from editors or transports that may have joined the header line with content.","Run a YAML linter to detect invalid characters after block scalar headers."],"exampleFix":"// before (content on header line)\ntext: | first line inline\n  more\n\n// after\ntext: |\n  first line\n  more","handlingStrategy":"validation","validationCode":"static bool BlockHeadersEndCleanly(string yaml)\n{\n    // content must not follow | or > (optionally with indicators) on the same line\n    return !System.Text.RegularExpressions.Regex.IsMatch(yaml, @\"[|>][0-9+-]*[ \t]+[^# \t\\\\r\\\\n]\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var obj = deserializer.Deserialize<T>(input);\n}\ncatch (YamlException ex)\n{\n    throw new FormatException($\"Invalid text after block scalar header at {ex.Start.Line}:{ex.Start.Column}\", ex);\n}","preventionTips":["Only an optional comment may follow a |/> header; then a line break","Put all block content on subsequent, more-indented lines","Check template engines do not leave text on the header line","Diff generated YAML against a known-good sample when headers change"],"tags":["yaml","parser","block-scalar"],"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"}