{"record":{"id":"f94ed9e3a9e6c270","repo":"stride3d/stride","slug":"expected-scalar-sequence-start-mapping-start-or-alias-got-0","errorCode":null,"errorMessage":"Expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS, got {0}","messagePattern":"Expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS, got (.+?)","errorType":"exception","errorClass":"YamlException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Emitter.cs","lineNumber":908,"sourceCode":"            {\n                case EventType.YAML_ALIAS_EVENT:\n                    EmitAlias();\n                    break;\n\n                case EventType.YAML_SCALAR_EVENT:\n                    EmitScalar(evt);\n                    break;\n\n                case EventType.YAML_SEQUENCE_START_EVENT:\n                    EmitSequenceStart(evt);\n                    break;\n\n                case EventType.YAML_MAPPING_START_EVENT:\n                    EmitMappingStart(evt);\n                    break;\n\n                default:\n                    throw new YamlException(string.Format(\"Expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS, got {0}\", eventType));\n            }\n        }\n\n        /// <summary>\n        /// Expect SEQUENCE-START.\n        /// </summary>\n        private void EmitSequenceStart(ParsingEvent evt)\n        {\n            ProcessAnchor();\n            ProcessTag();\n\n            SequenceStart sequenceStart = (SequenceStart) evt;\n\n            if (flowLevel != 0 || isCanonical || sequenceStart.Style == DataStyle.Compact || CheckEmptySequence())\n            {\n                state = EmitterState.YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE;\n            }\n            else","sourceCodeStart":890,"sourceCodeEnd":926,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Emitter.cs#L890-L926","documentation":"EmitterStateYamlException thrown by EmitterStateTransition when the event fed to the emitter is not a scalar, sequence-start, mapping-start, or alias. The emitter's state machine expected a node event but received some other event type (e.g. stream/document events out of order).","triggerScenarios":"Calling Emit with an event type outside {Scalar, SequenceStart, MappingStart, AnchorAlias} at a point where a node is expected — typically reusing an Emitter after a document ended, or feeding events in an order that violates the YAML event grammar.","commonSituations":"Custom emitters or event translators that skip DocumentStart/DocumentEnd pairing; retrying Emit after an earlier failure left the state machine mid-document; buggy event generators streaming events out of order.","solutions":["Emit events in valid YAML grammar order (StreamStart, DocumentStart, node events, DocumentEnd, StreamEnd)","Create a fresh Emitter instance instead of reusing one after a failure or completed document","Log/validate the event sequence before Emit and ensure only node events appear inside a document","Check the event type string in the message to find which producer emitted the wrong event"],"exampleFix":"// before\nemitter.Emit(new DocumentEnd(true, null, null)); // inside a node context\n// after\nemitter.Emit(new Scalar(null, null, \"value\", ScalarStyle.Plain, true, false, null, null));","handlingStrategy":"try-catch","validationCode":"var allowed = new[]{ EventType.YAML_SCALAR_EVENT, EventType.YAML_SEQUENCE_START_EVENT, EventType.YAML_MAPPING_START_EVENT, EventType.YAML_ALIAS_EVENT };\nbool ok = allowed.Contains(evt.Type);","typeGuard":null,"tryCatchPattern":"try { emitter.Emit(evt); }\ncatch (YamlException ex) when (ex.Message.StartsWith(\"Expected SCALAR\")) { /* restart emission with a fresh Emitter and a valid event order */ }","preventionTips":["Model emission as a strict state machine: StreamStart → DocumentStart → node → DocumentEnd → StreamEnd","Never reuse an Emitter after a failed or completed emission","Unit-test custom event producers with a round-trip parse"],"tags":["yaml","emitter","state-machine"],"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-16T04:17:20.429Z"}