Skip to content

Commit fb9d056

Browse files
authored
Make get_collection raise if collection_id is empty (#809)
1 parent 46e3fbc commit fb9d056

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- Make `get_collection` raise if `collection_id` is empty ([#809](https://github.com/stac-utils/pystac-client/pull/809))
13+
1014
## [v0.9.0] - 2025-07-17
1115

1216
### Added

pystac_client/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@ def get_collection(self, collection_id: str) -> Collection | CollectionClient:
396396
"""
397397
collection: Collection | CollectionClient | None = None
398398

399+
if not collection_id:
400+
raise ValueError("A `collection_id` must be provided.")
401+
399402
if self._supports_collections():
400403
assert self._stac_io is not None
401404

tests/test_client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,15 @@ def test_get_collection_for_static_catalogs_raise_if_not_found() -> None:
801801
client.get_collection("country-1")
802802

803803

804+
def test_get_collection_raises_if_collection_id_is_empty() -> None:
805+
client = Client.from_file(str(TEST_DATA / "test-case-1" / "catalog.json"))
806+
with pytest.raises(ValueError, match="A `collection_id` must be provided"):
807+
client.get_collection("")
808+
809+
with pytest.raises(ValueError, match="A `collection_id` must be provided"):
810+
client.get_collection(None)
811+
812+
804813
@pytest.mark.vcr
805814
def test_query_string_in_collections_url() -> None:
806815
# https://github.com/stac-utils/pystac-client/issues/745

0 commit comments

Comments
 (0)