diff --git a/pathfind.go b/pathfind.go
index 4c19075d33aefc0fefbfa46044067e54fc8b0321..8024f57d170beb9c7402c67b6196c64fc930fae8 100644
--- a/pathfind.go
+++ b/pathfind.go
@@ -72,6 +72,10 @@ func setValueUsingPath[D any](obj D, keyWithDots string, newValue string) error
 
 	}
 
+	if v.Kind() == reflect.Invalid {
+		return newInvalidPathError(keyWithDots)
+	}
+
 	for v.Kind() == reflect.Ptr {
 		v = v.Elem()
 	}