stride3d/stride · error · YamlException
Unable to parse input
Error message
Unable to parse input
What it means
TagTypeSerializer.ReadYaml throws this when it peeks the next parsing event and gets null, meaning the reader has no event available to process. Because there is no event, no start/end location can be attached to the YamlException.
Solutions
- Ensure the YAML input is a non-empty, well-formed document before deserializing.
- Check file/stream length and read the text first to fail early on empty input.
- Validate the YAML parses (e.g. with a parser round-trip) before handing it to this serializer.
- Fix the upstream producer that truncated the stream.
Example fix
// before
using var reader = new StreamReader(path); // file may be empty
var obj = serializer.Deserialize(reader);
// after
var text = File.ReadAllText(path);
if (string.IsNullOrWhiteSpace(text)) throw new InvalidDataException($"YAML file '{path}' is empty");
var obj = serializer.Deserialize(new StringReader(text)); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(yamlInput)) throw new InvalidDataException("YAML input is empty; nothing to deserialize"); Try / catch
try { return serializer.Deserialize(reader); } catch (YamlException ex) when (ex.Message == "Unable to parse input") { throw new InvalidDataException("YAML stream was empty or exhausted before a node was read", ex); } Prevention
- Check files are non-empty and fully written before deserializing.
- Validate download/write completion (flush, temp-file rename) before parsing.
- Fail early on blank config files with a clear message.
When it happens
Trigger: Calling ReadYaml on an exhausted/empty event stream; feeding an empty document to the deserializer; a corrupted or truncated YAML stream where the reader reaches EOF before a node event.
Common situations: Empty config files passed to a deserializer; truncated YAML from a failed download or interrupted write; calling the serializer pipeline on a reader positioned past the end of input.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Unexpected parsing event found
- Multiple identifiable objects with the same id
- Unable to decode asset part reference
- Unable to deserialize reference
- Unable to find class from tag
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/12eae5a766d0d8d6.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Serialization/Serializers/TagTypeSerializer.cs:62
// SOFTWARE.
using System;
using System.Collections.Generic;
using Stride.Core.Reflection;
using Stride.Core.Yaml.Events;
namespace Stride.Core.Yaml.Serialization.Serializers
{
internal class TagTypeSerializer : ChainedSerializer
{
public override object ReadYaml(ref ObjectContext objectContext)
{
var parsingEvent = objectContext.Reader.Peek<ParsingEvent>();
// Can this happen here?
if (parsingEvent == null)
{
// TODO check how to put a location in this case?
throw new YamlException("Unable to parse input");
}
var node = parsingEvent as NodeEvent;
if (node == null)
{
throw new YamlException(parsingEvent.Start, parsingEvent.End, $"Unexpected parsing event found [{parsingEvent}]. Expecting Scalar, Mapping or Sequence");
}
var type = objectContext.Descriptor != null ? objectContext.Descriptor.Type : null;
// Tries to get a Type from the TagTypes
Type typeFromTag = null;
if (!string.IsNullOrEmpty(node.Tag))
{
bool remapped;
typeFromTag = objectContext.SerializerContext.TypeFromTag(node.Tag, out remapped);
if (typeFromTag == null)
{View on GitHub (pinned to 96fad776d2)