Skip to content

Commit 9510020

Browse files
authored
Merge pull request #1299 from genematx/fix-properties-backcompat
FIX: backcompatibility issue with extra field
2 parents 857409e + 332c8bc commit 9510020

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Write the date in place of the "Unreleased" in the case a new version is release
1010

1111
- Raise an error with a suitable message when trying to create an API key
1212
on a server that does not support it.
13+
- Backwards compatibility with older servers that do not support the `properties`
14+
field in `DataSource` objects. The client will now omit this field when
15+
communicating with servers older than v0.2.4.
1316

1417
## v0.2.6 (2026-02-24)
1518

tiled/client/container.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import entrypoints
1414
import httpx
1515
import orjson
16+
from packaging.version import Version
1617

1718
from ..iterviews import ItemsView, KeysView, ValuesView
1819
from ..queries import KeyLookup
@@ -699,13 +700,24 @@ def new(
699700
metadata = metadata or {}
700701
access_blob = {"tags": access_tags} if access_tags is not None else {}
701702

703+
# Backompatibility: if the server is older than 0.2.4,
704+
# it can not accept the "properties" field in the data source.
705+
# This can be removed in later releases.
706+
if Version(self.context.server_info.library_version) < Version("0.2.4"):
707+
data_sources_as_dicts = [
708+
{k: v for k, v in asdict(ds).items() if k != "properties"}
709+
for ds in data_sources
710+
]
711+
else:
712+
data_sources_as_dicts = [asdict(ds) for ds in data_sources]
713+
702714
item = {
703715
"attributes": {
704716
"ancestors": self.path_parts,
705717
"metadata": metadata,
706718
"structure_family": StructureFamily(structure_family),
707719
"specs": normalize_specs(specs or []),
708-
"data_sources": [asdict(data_source) for data_source in data_sources],
720+
"data_sources": data_sources_as_dicts,
709721
"access_blob": access_blob,
710722
}
711723
}

0 commit comments

Comments
 (0)