data tree MAINTENANCE message improved
diff --git a/src/tree_data.c b/src/tree_data.c
index cc51c8f..ab092a2 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -1100,7 +1100,7 @@
     }
 
     if (parent && !parent->schema) {
-        LOGERR(ctx, LY_EINVAL, "Cannot add metadata to an opaque node \"%s\".", ((struct lyd_node_opaq *)parent)->name);
+        LOGERR(ctx, LY_EINVAL, "Cannot add metadata \"%s\" to an opaque node \"%s\".", name, LYD_NAME(parent));
         return LY_EINVAL;
     }
     if (meta) {