{"record":{"id":"46c345dcc944b767","repo":"stride3d/stride","slug":"expected-stream-start","errorCode":null,"errorMessage":"Expected STREAM-START.","messagePattern":"Expected STREAM-START\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Emitter.cs","lineNumber":644,"sourceCode":"                    break;\n\n                case EmitterState.YAML_EMIT_END_STATE:\n                    throw new YamlException(\"Expected nothing after STREAM-END\");\n\n                default:\n                    Debug.Assert(false, \"Invalid state.\");\n                    throw new InvalidOperationException(\"Invalid state\");\n            }\n        }\n\n        /// <summary>\n        /// Expect STREAM-START.\n        /// </summary>\n        private void EmitStreamStart(ParsingEvent evt)\n        {\n            if (!(evt is StreamStart))\n            {\n                throw new ArgumentException(\"Expected STREAM-START.\", \"evt\");\n            }\n\n            indent = -1;\n            line = 0;\n            column = 0;\n            isWhitespace = true;\n            isIndentation = true;\n\n            state = EmitterState.YAML_EMIT_FIRST_DOCUMENT_START_STATE;\n        }\n\n        /// <summary>\n        /// Expect DOCUMENT-START or STREAM-END.\n        /// </summary>\n        private void EmitDocumentStart(ParsingEvent evt, bool isFirst)\n        {\n            DocumentStart documentStart = evt as DocumentStart;\n            if (documentStart != null)","sourceCodeStart":626,"sourceCodeEnd":662,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Emitter.cs#L626-L662","documentation":"A new Emitter must receive a StreamStart event as the very first event; it initializes line/column/indent state from it. EmitStreamStart throws ArgumentException if the first event passed to Emit is anything other than StreamStart.","triggerScenarios":"Emitting a DocumentStart, Scalar, or any other event to a fresh Emitter without first emitting StreamStart.","commonSituations":"Hand-rolling an emitter loop and skipping the stream start; reusing an emitter mid-way after an exception left it in a fresh state; constructing events manually and forgetting StreamStart.","solutions":["Emit a StreamStart event first: emitter.Emit(new StreamStart());","Build the full event sequence StreamStart -> DocumentStart -> content -> DocumentEnd -> StreamEnd.","If using an EmittingEventQueue or serializer, ensure the serializer emits the stream envelope rather than suppressing it."],"exampleFix":"// before\nemitter.Emit(new DocumentStart()); // throws\n// after\nemitter.Emit(new StreamStart());\nemitter.Emit(new DocumentStart());","handlingStrategy":"validation","validationCode":"if (!(events.FirstOrDefault() is StreamStart))\n    emitter.Emit(new StreamStart()); // ensure stream envelope opens\nforeach (var evt in events) emitter.Emit(evt);","typeGuard":"bool StartsWithStreamStart(IEnumerable<ParsingEvent> events) => events.FirstOrDefault() is StreamStart;","tryCatchPattern":"try { emitter.Emit(evt); }\ncatch (ArgumentException ex) when (ex.Message == \"Expected STREAM-START.\") { /* restart with a fresh emitter and emit StreamStart first */ }","preventionTips":["Always open with StreamStart","Build the canonical StreamStart/DocumentStart/.../StreamEnd sequence","Prefer high-level serializers over manual Emit loops"],"tags":["yaml","event-stream","invalid-argument"],"backgroundTag":"invalid-state-transition","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"}