Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bad providers handling when searching by id #805

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions eodag/api/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1263,8 +1263,6 @@ def _search_by_id(self, uid, provider=None, **kwargs):
of EO products retrieved (0 or 1)
:rtype: tuple(:class:`~eodag.api.search_result.SearchResult`, int)
"""
if not provider:
provider = self.get_preferred_provider()[0]
get_search_plugins_kwargs = dict(
provider=provider, product_type=kwargs.get("productType", None)
)
Expand Down
11 changes: 9 additions & 2 deletions eodag/rest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from eodag.utils.exceptions import (
MisconfiguredError,
NoMatchingProductType,
NotAvailableError,
UnsupportedProductType,
ValidationError,
)
Expand Down Expand Up @@ -579,9 +580,15 @@ def download_stac_item_by_id_stream(catalogs, item_id, provider=None):
:returns: a stream of the downloaded data (either as a zip or the individual assets)
:rtype: StreamingResponse
"""
product = search_product_by_id(
search_results = search_product_by_id(
item_id, product_type=catalogs[0], provider=provider
)[0]
)
if len(search_results) > 0:
product = search_results[0]
else:
raise NotAvailableError(
f"Could not find {item_id} item in {catalogs[0]} collection for provider {provider}"
)
if product.downloader is None:
download_plugin = eodag_api._plugins_manager.get_download_plugin(product)
auth_plugin = eodag_api._plugins_manager.get_auth_plugin(
Expand Down