Open abunuwas opened 4 years ago
While this particular ticket hasn't been active since the OP's initial post, I can confirm that I'm seeing the same behavior. In my case the error (producing an uninformative error message exactly like OPs) was (accidentally) passing a set instead of a dictionary to a kwarg in dash_table.DataTable().
My environment is Windows 10 with the following Dash versions:
Please let me know if this has been resolved in a more recent Dash version, otherwise a fix to provide more informative error messages would be greatly appreciated.
The context Please provide us your environment so we can easily reproduce the issue.
pip list | grep dash
belowif frontend related, tell us your Browser, Version and OS
The bug
In a callback with multiple outputs, when one of the returned values is a Dash component which has been defined with a non-serializable type, Dash raises the wrong error - it fails to inspect the returned values and catch the actual element which is raising the error.
Expected behavior
I'd expect the validation logic to be able to inspect each of the returned values and catch the actual data type which is causing trouble. I'd expect the error message to tell me exactly which of the returned outputs is causing trouble and what is the data type which is causing the trouble.
Code snippers & screenshots
First, example of a simple app that produces this error:
When you click on the button, the callback tries to return two outputs, one of them is a dropdown in which the
options
are defined as a set, which is a non-serializable data type and causes Dash to fail. However, the error that I get is:It says the problem is a
tuple
, which is wrong (the tuple is the array of returned values). Also, see what happens if we change the callback to return a list of values:The result is this:
At this point something weird is happening in the validation and it's getting confusing. However, further down the trace in the above message, the real error pops up:
The following line in the code actually contains the correct error: https://github.com/plotly/dash/blob/526af0c6c50a99bb29277244818abc9f7959c894/dash/dash.py#L1001
(if you change that to
except TypeError as e:
and inspecte
, then you see the real source of the problem. )The problem is the next call to
fail_callback_output
doesn't get it right.