[pve-devel] [PATCH common 2/2] JSONSchema: don't cycle-check 'download' responses

Stefan Reiter s.reiter at proxmox.com
Thu Apr 1 17:30:09 CEST 2021


Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
---

Note that this happens before the result is put in '->{data}' so that part of
the previous patch is not necessary here.

 src/PVE/JSONSchema.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index 4864549..c29c777 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -1178,7 +1178,10 @@ sub validate {
     # we can disable that in the final release
     # todo: is there a better/faster way to detect cycles?
     my $cycles = 0;
-    find_cycle($instance, sub { $cycles = 1 });
+    # 'download' responses can contain a filehandle, don't cycle-check that as
+    # it produces a warning
+    my $is_download = ref($instance) eq 'HASH' && exists($instance->{download});
+    find_cycle($instance, sub { $cycles = 1 }) if !$is_download;
     if ($cycles) {
 	add_error($errors, undef, "data structure contains recursive cycles");
     } elsif ($schema) {
-- 
2.20.1






More information about the pve-devel mailing list