{"record":{"id":"c27403975835e9f7","repo":"stride3d/stride","slug":"did-not-find-expected-stream-start","errorCode":null,"errorMessage":"Did not find expected <stream-start>.","messagePattern":"Did not find expected <stream-start>\\.","errorType":"exception","errorClass":"SemanticErrorException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Parser.cs","lineNumber":223,"sourceCode":"            if (currentToken != null)\n            {\n                currentToken = null;\n                scanner.ConsumeCurrent();\n            }\n        }\n\n        /// <summary>\n        /// Parse the production:\n        /// stream   ::= STREAM-START implicit_document? explicit_document* STREAM-END\n        ///              ************\n        /// </summary>\n        private Event ParseStreamStart()\n        {\n            StreamStart streamStart = GetCurrentToken() as StreamStart;\n            if (streamStart == null)\n            {\n                var current = GetCurrentToken();\n                throw new SemanticErrorException(current.Start, current.End, \"Did not find expected <stream-start>.\");\n            }\n            Skip();\n\n            state = ParserState.YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE;\n            return new Events.StreamStart(streamStart.Start, streamStart.End);\n        }\n\n        /// <summary>\n        /// Parse the productions:\n        /// implicit_document    ::= block_node DOCUMENT-END*\n        ///                          *\n        /// explicit_document    ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*\n        ///                          *************************\n        /// </summary>\n        private Event ParseDocumentStart(bool isImplicit)\n        {\n            // Parse extra document end indicators.\n","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Parser.cs#L205-L241","documentation":"The parser's StateMachine calls ParseStreamStart to consume the initial STREAM-START token. If the first token from the scanner is not a StreamStart, the input does not begin as a valid YAML character stream and a SemanticErrorException is thrown at the token's source span.","triggerScenarios":"Parsing input whose tokenizer did not emit a leading StreamStart — typically malformed or non-YAML content passed to Parser.ReadYamlEvent/Parse, or a parser instance fed tokens out of order.","commonSituations":"Loading a config file that is actually JSON/binary/empty garbage, reading a file with a UTF-8 BOM handled incorrectly, or scanning an already-partially-consumed stream.","solutions":["Verify the input is valid YAML text before parsing (encoding, not JSON, not binary)","Parse via YamlStream/YamlDocument instead of driving Parser directly so the stream is set up correctly","Re-create the parser/scanner for a fresh input rather than reusing a consumed one"],"exampleFix":"// before\nvar parser = new Parser(new Scanner(reader));\nvar evt = parser.ReadYamlEvent(); // throws if first token isn't stream-start\n// after\nusing var rdr = new StreamReader(stream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true);\nvar stream2 = new YamlStream();\nstream2.Load(rdr); // handles stream framing correctly","handlingStrategy":"try-catch","validationCode":"var text = File.ReadAllText(path);\nif (string.IsNullOrWhiteSpace(text)) throw new InvalidDataException($\"{path} is empty\");\nif (text.TrimStart().StartsWith(\"{\")) throw new InvalidDataException($\"{path} looks like JSON, not YAML\");","typeGuard":null,"tryCatchPattern":"try { stream.Load(reader); } catch (SemanticErrorException ex) { throw new YamlConfigException($\"Invalid YAML stream: {ex.Message}\", ex); }","preventionTips":["Confirm files are real YAML before parsing","Create a fresh Parser/Scanner per input","Load with YamlStream rather than driving Parser manually"],"tags":["yaml","parser","syntax-error"],"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-15T23:17:13.987Z"}