# 'data' field is missing when predict returns a file

**URL:** <https://discuss.huggingface.co/t/data-field-is-missing-when-predict-returns-a-file/46868>\
**Category:** 🔒 Gradio\
**Created:** [July 14, 2023, 10:08pm UTC](https://discuss.huggingface.co/t/data-field-is-missing-when-predict-returns-a-file/46868 "2023-07-14T22:08:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bluman1](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/32.png) [@bluman1](https://discuss.huggingface.co/u/bluman1)\
**Post date:** [July 14, 2023, 10:08pm UTC](https://discuss.huggingface.co/t/data-field-is-missing-when-predict-returns-a-file/46868/1 "2023-07-14T22:08:22Z")

</div>

I am using the Gradio API to access a private HF Space and whenever the response is supposed to be a file, I get the following error

```auto
File ".../venv/lib/python3.8/site-packages/gradio_client/serializing.py", line 294, in _deserialize_single
    assert data is not None, f"The 'data' field is missing in {x}"
AssertionError: The 'data' field is missing in {'value': {'name': '/tmp/gradio/b067c151fedfffa4ccf49e831cbe080379a537e3/audio.wav', 'data': None, 'is_file': True}, ' __type__': 'update'}

```

Below is the code I am running that is giving the error.

```auto
client = Client("https://my-private-space.hf.space/", hf_token=HF_TOKEN)

# generating audio from local language text
result = client.predict(
				"some text",
				"eng: English",
				0.1,
				api_name="/predict"
)

```

According to the error message, the Gradio client on GitHub [should direct code execution](https://github.com/gradio-app/gradio/blob/9137f1caa015ba361ab2dacdd9b0071645a692ef/client/python/gradio_client/serializing.py#L281) to Line 281 in gradio\_client/serializing.py, but the code execution jumps to [Line 292](https://github.com/gradio-app/gradio/blob/9137f1caa015ba361ab2dacdd9b0071645a692ef/client/python/gradio_client/serializing.py#L292) because it thinks “is\_file” should be a key in the main dict it is reading.

I am unsure if this is a bug with the Gradio client or if something is wrong with my code that is pushing “is\_file” into another dict under the key “value”.

Can anyone help with this?

---

<div class="post-metadata">

**Author:** ![freddyaboulton](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/freddyaboulton/32/32732_2.png) [@freddyaboulton](https://discuss.huggingface.co/u/freddyaboulton)\
**Post date:** [July 14, 2023, 10:22pm UTC](https://discuss.huggingface.co/t/data-field-is-missing-when-predict-returns-a-file/46868/2 "2023-07-14T22:22:28Z")

</div>

Hi @bluman1 - are you returning gr.File.update instead of the path to a new file in your private space? I think that’s what’s causing the issue. I think this is a bug in gradio though. What version of gradio is the space using?

---

<div class="post-metadata">

**Author:** ![bluman1](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/32.png) [@bluman1](https://discuss.huggingface.co/u/bluman1)\
**Post date:** [July 14, 2023, 10:51pm UTC](https://discuss.huggingface.co/t/data-field-is-missing-when-predict-returns-a-file/46868/3 "2023-07-14T22:51:52Z")

</div>

I am using v0.2.8

How will I return gr.File.update instead of the path to a new file?  
The ideal response from the predict endpoint is supposed to be a file that I can save based on the temporary file I can see in the error response - ‘/tmp/gradio/b067c151fedfffa4ccf49e831cbe080379a537e3/audio.wav’

Here’s the full error log to make it easier

```auto
Traceback (most recent call last):
  File ".../code.py", line 8, in <module>
    result = client.predict(
  File "../venv/lib/python3.8/site-packages/gradio_client/client.py", line 285, in predict
    return self.submit(*args, api_name=api_name, fn_index=fn_index).result()
  File "../venv/lib/python3.8/site-packages/gradio_client/client.py", line 982, in result
    raise self.future._exception # type: ignore
  File "../.pyenv/versions/3.8.5/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "../venv/lib/python3.8/site-packages/gradio_client/client.py", line 646, in _inner
    predictions = self.process_predictions(*predictions)
  File "../venv/lib/python3.8/site-packages/gradio_client/client.py", line 836, in process_predictions
    predictions = self.deserialize(*predictions)
  File "../venv/lib/python3.8/site-packages/gradio_client/client.py", line 822, in deserialize
    [
  File "../venv/lib/python3.8/site-packages/gradio_client/client.py", line 823, in <listcomp>
    s.deserialize(
  File "../venv/lib/python3.8/site-packages/gradio_client/serializing.py", line 349, in deserialize
    return self._deserialize_single(
  File "../venv/lib/python3.8/site-packages/gradio_client/serializing.py", line 294, in _deserialize_single
    assert data is not None, f"The 'data' field is missing in {x}"
AssertionError: The 'data' field is missing in {'value': {'name': '/tmp/gradio/b067c151fedfffa4ccf49e831cbe080379a537e3/audio.wav', 'data': None, 'is_file': True}, ' __type__': 'update'}

```
