stride3d/stride · error · ArgumentException

The current event is of an unsupported type.

Error message

The current event is of an unsupported type.

What it means

Thrown by YamlNode.ParseNode when the current parser event is neither a scalar, sequence, mapping, nor anchor alias — i.e. an event type the node parser does not know how to convert into a YamlNode. It indicates a malformed or unexpected YAML event stream rather than bad user input.

Solutions

  1. Validate the YAML document parses with a standard parser before loading
  2. Check the input file for truncation or corruption at the reported location
  3. Catch ArgumentException around parsing and surface the file/line to the user

Example fix

// before
var node = YamlNode.Parse(events, state);
// after
YamlNode node;
try { node = YamlNode.Parse(events, state); }
catch (ArgumentException e) { throw new YamlException("Unsupported YAML event while parsing node", e); }
Defensive patterns

Strategy: try-catch

Validate before calling

// Parse with a validation pass first
using var reader = new StringReader(yamlText);
new YamlStream().Load(reader); // throws earlier with position info if malformed

Type guard

null

Try / catch

try { var node = YamlNode.Parse(events, state); } catch (ArgumentException ex) { throw new YamlException("Unsupported YAML event; document may be malformed", ex); }

Prevention

When it happens

Trigger: Parsing a YAML document whose current event is of a type not handled by ParseNode (e.g. stream/document-level events reaching node-parsing code), typically due to corrupted or non-standard YAML input.

Common situations: Feeding truncated or malformed YAML files to the asset deserializer; parser state desync after a prior parse error.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/a28806c0f6d8a0c7. Report an issue: GitHub.

Appendix: source

Thrown at sources/core/Stride.Core.Yaml/Serialization/YamlNode.cs:125

            }

            if (events.Accept<SequenceStart>())
            {
                return new YamlSequenceNode(events, state);
            }

            if (events.Accept<MappingStart>())
            {
                return new YamlMappingNode(events, state);
            }

            if (events.Accept<AnchorAlias>())
            {
                AnchorAlias alias = events.Expect<AnchorAlias>();
                return state.GetNode(alias.Value, false, alias.Start, alias.End) ?? new YamlAliasNode(alias.Value);
            }

            throw new ArgumentException("The current event is of an unsupported type.", "events");
        }

        /// <summary>
        /// Resolves the aliases that could not be resolved when the node was created.
        /// </summary>
        /// <param name="state">The state of the document.</param>
        internal abstract void ResolveAliases(DocumentLoadingState state);

        /// <summary>
        /// Saves the current node to the specified emitter.
        /// </summary>
        /// <param name="emitter">The emitter where the node is to be saved.</param>
        /// <param name="state">The state.</param>
        internal void Save(IEmitter emitter, EmitterState state)
        {
            if (!string.IsNullOrEmpty(Anchor) && !state.EmittedAnchors.Add(Anchor))
            {
                emitter.Emit(new AnchorAlias(Anchor));

View on GitHub (pinned to 96fad776d2)