{"record":{"id":"55ba6a6700a8a512","repo":"stride3d/stride","slug":"unexpected-parsing-event-found-parsingevent-expecting-scalar","errorCode":null,"errorMessage":"Unexpected parsing event found [{parsingEvent}]. Expecting Scalar, Mapping or Sequence","messagePattern":"Unexpected parsing event found \\[(.+?)\\]\\. Expecting Scalar, Mapping or Sequence","errorType":"exception","errorClass":"YamlException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Serialization/Serializers/TagTypeSerializer.cs","lineNumber":68,"sourceCode":"\nnamespace Stride.Core.Yaml.Serialization.Serializers\n{\n    internal class TagTypeSerializer : ChainedSerializer\n    {\n        public override object ReadYaml(ref ObjectContext objectContext)\n        {\n            var parsingEvent = objectContext.Reader.Peek<ParsingEvent>();\n            // Can this happen here?\n            if (parsingEvent == null)\n            {\n                // TODO check how to put a location in this case?\n                throw new YamlException(\"Unable to parse input\");\n            }\n\n            var node = parsingEvent as NodeEvent;\n            if (node == null)\n            {\n                throw new YamlException(parsingEvent.Start, parsingEvent.End, $\"Unexpected parsing event found [{parsingEvent}]. Expecting Scalar, Mapping or Sequence\");\n            }\n\n            var type = objectContext.Descriptor != null ? objectContext.Descriptor.Type : null;\n\n            // Tries to get a Type from the TagTypes\n            Type typeFromTag = null;\n            if (!string.IsNullOrEmpty(node.Tag))\n            {\n                bool remapped;\n                typeFromTag = objectContext.SerializerContext.TypeFromTag(node.Tag, out remapped);\n                if (typeFromTag == null)\n                {\n                    throw new YamlException(parsingEvent.Start, parsingEvent.End, $\"Unable to resolve tag [{node.Tag}] to type from tag resolution or registered assemblies\");\n                }\n\n                // Store the fact that remap has occured on this tag\n                if (remapped)\n                {","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Serialization/Serializers/TagTypeSerializer.cs#L50-L86","documentation":"TagTypeSerializer.ReadYaml expects the next parsing event to be a NodeEvent (Scalar, MappingStart, or SequenceStart). If the peeked event is any other ParsingEvent (e.g. DocumentEnd, StreamEnd, or a collection end event), it throws this YamlException with the event's location.","triggerScenarios":"A YAML document whose structure ends unexpectedly where a node is required — e.g. a document that is just '---' with no content, trailing document markers, or a stream misaligned so a collection-end event is read as a node.","commonSituations":"YAML files containing only comments or a bare document start marker; concatenated/malformed multi-document streams; deserializing with the reader positioned incorrectly inside a nested structure.","solutions":["Ensure the YAML document actually contains a value (not just '---' or comments).","Validate the YAML structure with a standard parser before deserialization.","Check for stray '---'/'...' markers or unbalanced flow collections in the input.","Fix the deserialization call site so the reader starts at the beginning of the document."],"exampleFix":"// before (file.yaml)\n---\n---\n// after\nkey: value","handlingStrategy":"validation","validationCode":"// Ensure document has content before deserializing\nif (!yamlText.TrimStart().TrimStart('-',' ').Trim().Any(char.IsLetterOrDigit))\n    throw new InvalidDataException(\"YAML document contains no value (only markers/comments)\");","typeGuard":null,"tryCatchPattern":"try { return serializer.Deserialize(reader); } catch (YamlException ex) when (ex.Message.Contains(\"Unexpected parsing event\")) { throw new InvalidDataException($\"Malformed YAML at {ex.Start}: expected Scalar/Mapping/Sequence\", ex); }","preventionTips":["Strip stray '---'/'...' markers and trailing document ends from generated YAML.","Parse-validate with a standard YAML library before handing to the serializer.","Keep the reader positioned at document start; do not reuse partially-consumed readers."],"tags":["yaml","deserialization","parse","unexpected-event"],"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"}