Open kasuteru opened 3 years ago
I just spent two hours trying to debug a callback updating a table's columns and data, turns out this was the problem. I kept getting a dash.exceptions.InvalidCallbackReturnValue when updating with some specific data, the error message saying the callback returned a tuple. This left me pretty confused since my callback always returns df.to_dict('records')
, and i couldn't find any difference in the type or format of the data explaining why it would crash in some cases. Turns out there were some <NA>
values sprinkled around my data causing the error, removing them seems to have fixed the issue.
Anyways, thanks for pointing this out, i'm not sure i would have firugred it out. Here's the full return statement and the error if it's any help:
return [{'name': map_name(c), 'id': c} for c in cols], df[cols].to_dict('records')
dash.exceptions.InvalidCallbackReturnValue: The callback for `[<Output `fmsq-table.columns`>, <Output `fmsq-table.data`>]`
returned a value having type `tuple`
which is not JSON serializable.
Pandas now uses an experimental NA declarator by default:
pandas.NA
of typepandas._libs.missing.NAType
. More details here.Currently, dash_table throws an "Error loading layout" during runtime whenever it encounters a table with one of these values. This is very hard to debug since a) it might not occur in development / testing and crash the app in production b) the error message is very unspecific, making it hard to find the problem.
Example code: