Skip to content

Commit 462d79c

Browse files
committed
BUG: handle list-shaped response data in _model_dump_backcompat
The helper assumed `response["data"]` was always a dict of a single resource (as in GET metadata), but search responses shape it as a list of resources. Normalize to iterate resources uniformly and collect data_sources from all of them before stripping.
1 parent 9a71f62 commit 462d79c

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

tiled/server/router.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,11 +2826,15 @@ def _model_dump_backcompat(request: Request, response: schemas.Response) -> dict
28262826
client_version = parse_python_tiled_client_version(request)
28272827
if client_version is None:
28282828
return response_dict
2829-
data_sources = (response_dict.get("data") or {}).get("attributes", {}).get(
2830-
"data_sources"
2831-
) or []
2829+
data = response_dict.get("data") or []
2830+
resources = data if isinstance(data, list) else [data]
2831+
all_data_sources = [
2832+
ds
2833+
for resource in resources
2834+
for ds in (resource.get("attributes", {}) or {}).get("data_sources") or []
2835+
]
28322836
if client_version < packaging.version.parse("0.2.4"):
2833-
for ds in data_sources:
2837+
for ds in all_data_sources:
28342838
ds.pop("properties", None)
2835-
strip_asset_fields_for_client(data_sources, client_version)
2839+
strip_asset_fields_for_client(all_data_sources, client_version)
28362840
return response_dict

0 commit comments

Comments
 (0)