diff --git a/saphyr/node.cc b/saphyr/node.cc index d1593ca..8cd6aba 100644 --- a/saphyr/node.cc +++ b/saphyr/node.cc @@ -205,7 +205,11 @@ absl::StatusOr Load(rs_std::StrRef input) { StringViewFromVecU8(std::move(result).err())); } rust::NodeOwned docs = std::move(result).value(); - return Node(docs.get_at_index(0)->to_owned()); + std::optional first_doc = docs.get_at_index(0); + if (!first_doc.has_value()) { + return absl::InvalidArgumentError("Empty YAML document"); + } + return Node(first_doc->to_owned()); } rust::YamlOwned ToYaml(int64_t value) {