diff --git a/libgnucash/engine/kvp-frame.cpp b/libgnucash/engine/kvp-frame.cpp
index f1368bc2d..f32209613 100644
--- a/libgnucash/engine/kvp-frame.cpp
+++ b/libgnucash/engine/kvp-frame.cpp
@@ -125,6 +125,8 @@ walk_path_or_nullptr(const KvpFrameImpl* frame, Path& path)
 KvpValue*
 KvpFrameImpl::set(Path path, KvpValue* value) noexcept
 {
+    if (path.empty())
+        return nullptr;
     auto last_key = path.back();
     path.pop_back();
     auto cur_frame = walk_path_or_nullptr(this, path);
