plotly / dash-sample-apps

Open-source demos hosted on Dash Gallery
https://dash.gallery
MIT License
3.16k stars 3.04k forks source link

orjson inserts random character causing Syntax error in html when converting app layout to json #764

Closed bondeje closed 1 year ago

bondeje commented 1 year ago

App name

dash-manufacture-spc-dashboard

Description of bug

Attempting to run the dash-manufacture-spc-dashboard example results in a Loading... page. Console shows syntax error in JSON. image

It is due to how the Dash.layout is dumped to json string, but unclear if it is just an issue with orjson or how layout structure is passed to orjson. Likely this is an orjson issue and can be closed/submitted to orjson as an issue, but I don't yet know what about the Layout structure is causing problems. It appears to only happen in the one place pictured below in a single html.Div but nowhere else.

How to replicate the bug

clone the .git for dash-sample-apps and install requirements per README.md run the dash-manufacture-spc-dashboard

relevant versions/environment: Miniconda3/CPython 3.9.5 Windows 10 Chrome: 108.0.5359.125 dash==2.7.1 (core & html components are 2.0.0) orjson==3.8.4 plotly==5.11.0

Other notes

running using default json engine (default is "orjson") image the '(' character in the image (it appears to be random) needs to be ',' for valid json.

"fixed" by modifying plotly.io._json.py to have to_json_plotly use the "json" engine by default rather than "orjson" image

running setting the engine to use "json" by default image

bondeje commented 1 year ago

Sounds like this: orjson issue #331 Confirmed orjson 3.8.3 is OK, but orjson 3.8.4 is not OK.

bondeje commented 1 year ago

orjson released 3.8.5 on 1/10/2023 which fixed the issue