diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e866f36d..45b384416 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,10 @@ ## [Unreleased] -- Allow object ID as input for getting APILayoutStrategy hrefs and add `items`, `collections`, `search`, `conformance`, `service_desc` and `service_doc` href methods. ([#1335](https://github.com/stac-utils/pystac/pull/1335)) +### Fixed +- Don't transform hrefs in `Item.__getstate__` ([#1337](https://github.com/stac-utils/pystac/pull/1337)) +- Allow object ID as input for getting APILayoutStrategy hrefs and add `items`, `collections`, `search`, `conformance`, `service_desc` and `service_doc` href methods. ([#1335](https://github.com/stac-utils/pystac/pull/1335)) ## [v1.10.0] - 2024-03-28 diff --git a/pystac/item.py b/pystac/item.py index 0d907a8e4..217d7e584 100644 --- a/pystac/item.py +++ b/pystac/item.py @@ -177,7 +177,12 @@ def __getstate__(self) -> dict[str, Any]: d = self.__dict__.copy() d["links"] = [ - link.to_dict() if link.get_href() else link for link in d["links"] + ( + link.to_dict(transform_href=False) + if link.get_href(transform_href=False) + else link + ) + for link in d["links"] ] return d diff --git a/tests/test_item.py b/tests/test_item.py index 3eab34766..db907db7e 100644 --- a/tests/test_item.py +++ b/tests/test_item.py @@ -1,5 +1,6 @@ from __future__ import annotations +import copy import json import os import pickle @@ -682,3 +683,12 @@ def test_pickle_with_only_href_links(item: Item) -> None: assert original.media_type == new.media_type assert str(original.owner) == str(new.owner) assert str(original.target) == str(new.target) + + +def test_copy_with_unresolveable_root(item: Item) -> None: + item.add_link( + pystac.Link( + "root", "s3://naip-visualization/this-is-a-non-existent-catalog.json" + ) + ) + copy.deepcopy(item)