UnBoundLocalError in documentation code of Upload component

I’m trying to run the first code section in the documentation of the Upload component: https://dash.plot.ly/dash-core-components/upload

Uploading to the running example on the page does nothing.

When I run the example locally and upload a image file, I get “UnboundLocalError: local variable ‘df’ referenced before assignment”.
The full trace is:

Traceback (most recent call last):
  File "/home/2024/sandbox/upload_file.py", line 86, in update_output
    children = [
  File "/home/2024/sandbox/upload_file.py", line 87, in <listcomp>
    parse_contents(c, n, d) for c, n, d in
  File "/home/2024/sandbox/upload_file.py", line 65, in parse_contents
UnboundLocalError: local variable 'df' referenced before assignment

Hi @2024
If “df” in this line of code “data=df.to_dict(‘records’)” is the first time you mention “df”, then the error is that you didnt define df outside the callback.