{"record":{"id":"033200de962b59cf","repo":"stride3d/stride","slug":"unable-to-load-the-given-stream","errorCode":null,"errorMessage":"Unable to load the given stream","messagePattern":"Unable to load the given stream","errorType":"exception","errorClass":"YamlException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets.Yaml/DynamicYaml/DynamicYaml.cs","lineNumber":47,"sourceCode":"        {\n            using var assetStreamReader = new StreamReader(stream, Encoding.UTF8);\n            assetAsString = assetStreamReader.ReadToEnd();\n        }\n        finally\n        {\n            if (disposeStream)\n            {\n                stream.Dispose();\n            }\n        }\n\n        // Load the asset as a YamlNode object\n        var input = new StringReader(assetAsString);\n        yamlStream = [];\n        yamlStream.Load(input);\n\n        if (yamlStream.Documents.Count != 1 || yamlStream.Documents[0].RootNode is not YamlMappingNode)\n            throw new YamlException(\"Unable to load the given stream\");\n    }\n\n    /// <summary>\n    /// Initializes a new instance of <see cref=\"DynamicYaml\"/> from the specified stream.\n    /// </summary>\n    /// <param name=\"text\">A text that contains a YAML content</param>\n    public DynamicYaml(string text) : this(GetSafeStream(text))\n    {\n    }\n    /// <summary>\n    /// Gets the root YAML node.\n    /// </summary>\n    public YamlMappingNode RootNode => (YamlMappingNode)yamlStream.Documents[0].RootNode;\n\n    /// <summary>\n    /// Gets a dynamic YAML node around the <see cref=\"RootNode\"/>.\n    /// </summary>\n    public dynamic DynamicRootNode => dynamicRootNode ??= new DynamicYamlMapping(RootNode);","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets.Yaml/DynamicYaml/DynamicYaml.cs#L29-L65","documentation":"DynamicYaml parses YAML text and requires the stream to contain exactly one document whose root is a YAML mapping. If the parse yields zero documents, multiple documents, or a non-mapping root (sequence/scalar), it throws YamlException(\"Unable to load the given stream\").","triggerScenarios":"Constructing DynamicYaml from a string/stream that: is empty or malformed YAML (parse itself degrades), contains multiple --- separated documents, or has a root node that is a sequence (\"- a\\n- b\") or scalar (\"just text\") instead of a mapping.","commonSituations":"Asset YAML edited by hand and broken; concatenated asset files with multiple documents; loading a list-style YAML where a top-level map (with !Name/Id tags) is required; wrong file passed (e.g. a log or binary file).","solutions":["Fix the YAML text so it is a single top-level mapping (key: value at root), like a normal Stride asset file.","Remove extra '---' document separators so only one document remains.","Validate the YAML with a parser/YAML linter before constructing DynamicYaml.","Ensure the input string is the actual asset content, not empty, truncated, or a different file type."],"exampleFix":"// before\nvar yaml = new DynamicYaml(\"- a\\n- b\"); // root is a sequence -> throws\n// after\nvar yaml = new DynamicYaml(\"Items:\\n- a\\n- b\"); // root is a mapping","handlingStrategy":"validation","validationCode":"bool isSingleMapping = text.Trim().Length > 0 && !text.TrimStart().StartsWith(\"-\") && text.CountOccurrences(\"\\n---\") == 0;","typeGuard":"static bool IsYamlMappingStream(YamlStream s) =>\n    s.Documents.Count == 1 && s.Documents[0].RootNode is YamlMappingNode;","tryCatchPattern":"try { var yaml = new DynamicYaml(text); }\ncatch (YamlException) { /* invalid or multi-document YAML */ }","preventionTips":["Ensure exactly one YAML document per asset file","Keep a top-level mapping root in asset YAML","Lint YAML content before loading","Confirm the loaded file is the intended asset, not empty or foreign content"],"tags":["yaml","parsing","stride","assets"],"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"}