JS Client: Fixes cannot read properties of null (reading 'is_file') (#5035)

* In transform_output, typeof d can be an object even if the property is_file doesn't exist on d. Therefore invoking d.is_file will error out. This commit fixes that by failing quietly if the is_file property doesn't exist on d.

* Update client.ts - fixed spacing

fixed spacing

* add changeset

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
Ray Tri 2023-08-01 12:16:20 -04:00 committed by GitHub
parent 883ac364f6
commit 8b4eb8cac9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -0,0 +1,6 @@
---
"@gradio/client": minor
"gradio": minor
---
feat:JS Client: Fixes cannot read properties of null (reading 'is_file')

View File

@ -776,7 +776,7 @@ function transform_output(
? [normalise_file(img[0], root_url, remote_url), img[1]]
: [normalise_file(img, root_url, remote_url), null];
});
} else if (typeof d === "object" && d.is_file) {
} else if (typeof d === "object" && d?.is_file) {
return normalise_file(d, root_url, remote_url);
} else {
return d;