From ebe6e0ff48c167fd3e9f969e3387b83e37045150 Mon Sep 17 00:00:00 2001 From: Cameron DeCoster Date: Thu, 23 Apr 2026 14:50:41 -0600 Subject: [PATCH 1/2] fix: Add default request headers to Kaleido calls --- plotly/io/_defaults.py | 3 +++ plotly/io/_kaleido.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/plotly/io/_defaults.py b/plotly/io/_defaults.py index c36530c342d..ba4e48b18e1 100644 --- a/plotly/io/_defaults.py +++ b/plotly/io/_defaults.py @@ -14,6 +14,9 @@ def __init__(self): self.mathjax = None self.topojson = None self.plotlyjs = None + # This header is necessary to comply with Open Street Map tile policy: + # https://openstreetmap.github.io/owg-website/policies/tiles/#31-identification + self.headers = {"X-Requested-With": "plotly.py"} defaults = _Defaults() diff --git a/plotly/io/_kaleido.py b/plotly/io/_kaleido.py index d0bb0eec438..09a6edafdf6 100644 --- a/plotly/io/_kaleido.py +++ b/plotly/io/_kaleido.py @@ -375,6 +375,8 @@ def to_image( kopts["plotlyjs"] = defaults.plotlyjs if defaults.mathjax: kopts["mathjax"] = defaults.mathjax + if defaults.headers: + kopts["headers"] = defaults.headers width = ( width @@ -712,6 +714,8 @@ def write_images( kopts["plotlyjs"] = defaults.plotlyjs if defaults.mathjax: kopts["mathjax"] = defaults.mathjax + if defaults.headers: + kopts["headers"] = defaults.headers kaleido.write_fig_from_object_sync( kaleido_specs, kopts=kopts, From 05a0d556df582064a43eb782f149e9fbde2126d8 Mon Sep 17 00:00:00 2001 From: Cameron DeCoster Date: Mon, 4 May 2026 16:48:56 -0600 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3844a7e2c41..ccc184c23af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Fix issue where user-specified `color_continuous_scale` was ignored when template had `autocolorscale=True` [[#5439](https://github.com/plotly/plotly.py/pull/5439)], with thanks to @antonymilne for the contribution! - Use presence of `COLAB_NOTEBOOK_ID` env var to enable Colab renderer instead of testing import of `google.colab` [[#5473](https://github.com/plotly/plotly.py/pull/5473)], with thanks to @kevineger for the contribution! - Update tests to be compatible with numpy 2.4 [[#5522](https://github.com/plotly/plotly.py/pull/5522)], with thanks to @thunze for the contribution! +- Add default headers to be passed in to Kaleido v1.3.0 to avoid blocked Open Street Map tiles [#5588](https://github.com/plotly/plotly.py/pull/5588)] ### Updated - The `__eq__` method for `graph_objects` classes now returns `NotImplemented` to give the other operand an opportunity to handle the comparison [[#5547](https://github.com/plotly/plotly.py/pull/5547)], with thanks to @RazerM for the contribution!