Skip to content

Commit

Permalink
Make sure that get_items does not recurse (#608)
Browse files Browse the repository at this point in the history
Since we were ignoring the `recursive` argument, you could enter a recursion loop
  • Loading branch information
jsignell authored Oct 30, 2023
1 parent 0ba5d7a commit df9b213
Show file tree
Hide file tree
Showing 4 changed files with 562 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed

- Recursion error in `get_items` [#608](https://github.com/stac-utils/pystac-client/pull/608)

## [v0.7.5] - 2023-09-05

### Fixed
Expand Down
10 changes: 7 additions & 3 deletions pystac_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,14 @@ def get_collections(self) -> Iterator[Collection]:
call_modifier(self.modifier, collection)
yield collection

def get_items(self, *ids: str, recursive: bool = False) -> Iterator["Item_Type"]:
def get_items(
self, *ids: str, recursive: Optional[bool] = None
) -> Iterator["Item_Type"]:
"""Return all items of this catalog.
Args:
ids: Zero or more item ids to find.
recursive: unused
recursive: unused in pystac-client, but needed for falling back to pystac
Return:
Iterator[Item]: Iterator of items whose parent is this
Expand All @@ -454,7 +456,9 @@ def get_items(self, *ids: str, recursive: bool = False) -> Iterator["Item_Type"]
yield from search.items()
else:
self._warn_about_fallback("ITEM_SEARCH")
for item in super().get_items(*ids, recursive=True):
for item in super().get_items(
*ids, recursive=recursive is None or recursive
):
call_modifier(self.modifier, item)
yield item

Expand Down
Loading

0 comments on commit df9b213

Please sign in to comment.