1.3 serialization regression: `calc_fig` fails on numbers outside 64-bit range
Open
@camdecoster is already working on this.
Since Jul 22, 2026.
bug
P1
size: 3
- Dominant language
- Python
- Stars
- 498
- Forks
- 62
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 2
Description
Kaleido().calc_fig() fails when figure contains numbers outside the 64-bit range, which in practice seems to be anything equal to or greater than 2**64.
This seems to be due to an orjson limitation, and the same figure does not fail in Kaleido v1.2.
Steps to reproduce:
Run the following code with Kaleido 1.3 installed:
import plotly.express as px
fig = px.scatter(x=[1], y=[2**64])
fig.write_image(file="test.png")
Stack trace:
Traceback (most recent call last):
File "/Users/ekl/code/plotly.js/64bit-bug.py", line 3, in <module>
fig.write_image(file="test.png")
File "/Users/ekl/code/plotly.js/venv/plotly.js/lib/python3.12/site-packages/plotly/basedatatypes.py", line 3895, in write_image
return pio.write_image(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ekl/code/plotly.js/venv/plotly.js/lib/python3.12/site-packages/plotly/io/_kaleido.py", line 530, in write_image
img_data = to_image(
^^^^^^^^^
File "/Users/ekl/code/plotly.js/venv/plotly.js/lib/python3.12/site-packages/plotly/io/_kaleido.py", line 400, in to_image
img_bytes = kaleido.calc_fig_sync(
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ekl/code/plotly.js/venv/plotly.js/lib/python3.12/site-packages/kaleido/__init__.py", line 170, in calc_fig_sync
return _sync_server.oneshot_async_run(calc_fig, args=args, kwargs=kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ekl/code/plotly.js/venv/plotly.js/lib/python3.12/site-packages/kaleido/_sync_server.py", line 161, in oneshot_async_run
raise res
File "/Users/ekl/code/plotly.js/venv/plotly.js/lib/python3.12/site-packages/kaleido/_sync_server.py", line 152, in run
q.put(asyncio.run(func(*args, **kwargs)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.9/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 195, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.9/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.9/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 691, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/ekl/code/plotly.js/venv/plotly.js/lib/python3.12/site-packages/kaleido/__init__.py", line 104, in calc_fig
return await k.calc_fig(
^^^^^^^^^^^^^^^^^
File "/Users/ekl/code/plotly.js/venv/plotly.js/lib/python3.12/site-packages/kaleido/kaleido.py", line 618, in calc_fig
return await self.write_fig_from_object( # type: ignore[reportCallIssue]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ekl/code/plotly.js/venv/plotly.js/lib/python3.12/site-packages/kaleido/kaleido.py", line 493, in write_fig_from_object
res = await asyncio.gather(*tasks, return_exceptions=not cancel_on_error)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ekl/code/plotly.js/venv/plotly.js/lib/python3.12/site-packages/kaleido/kaleido.py", line 358, in _render_task
img_bytes = await asyncio.wait_for(
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.9/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
return await fut
^^^^^^^^^
File "/Users/ekl/code/plotly.js/venv/plotly.js/lib/python3.12/site-packages/kaleido/_kaleido_tab/_tab.py", line 152, in _calc_fig
spec_str = orjson.dumps(
^^^^^^^^^^^^^
TypeError: Integer exceeds 64-bit range
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.