Skip to content

In case of misconfiguration of dataset.encoding unlimited_dims warn instead of raise #10648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Bug fixes
~~~~~~~~~
- Fix distribution of ``auto_complex`` keyword argument for open_datatree (:issue:`10631`, :pull:`10632`).
By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
- Warn instead of raise in case of misconfiguration of ``unlimited_dims`` originating from dataset.encoding, to prevent breaking users workflows (:issue:`10647`, :pull:`10648`).
By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.


Documentation
Expand Down
5 changes: 4 additions & 1 deletion xarray/backends/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ def _sanitize_unlimited_dims(dataset, unlimited_dims):
f"but not part of current dataset dimensions. "
f"Consider removing {undeclared_dims!r} from {msg_origin!r}."
)
raise ValueError(msg)
if msg_origin == "unlimited_dims-kwarg":
raise ValueError(msg)
else:
emit_user_level_warning(msg)
return unlimited_dims


Expand Down
4 changes: 2 additions & 2 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -1399,8 +1399,8 @@ def test_encoding_unlimited_dims(self) -> None:
# test unlimited_dims validation
# https://github.com/pydata/xarray/issues/10549
ds.encoding = {"unlimited_dims": "z"}
with pytest.raises(
ValueError,
with pytest.warns(
UserWarning,
match=r"Unlimited dimension\(s\) .* declared in 'dataset.encoding'",
):
with self.roundtrip(ds) as _:
Expand Down
Loading