Repository: CS-SI/eodag

Issue:
Fail to fetch product types with geodes_s3
**Describe the bug**
`result_type`, the required key in provider `discover_product_types` configuration, is missing when we try to fetch product types with `geodes_s3`.

**Code To Reproduce**
First, add mock or real credentials to `geodes_s3` configuration in `eodag.yml`. Then run the following code:
```py
from eodag import EODataAccessGateway
from eodag.utils.logging import setup_logging

setup_logging(verbose=3)
dag = EODataAccessGateway()

extended_catalog = dag.list_product_types()
```

**Output**
```py
2025-02-11 15:39:43,718 eodag.config                     [DEBUG   ] Loading configuration from /home/anesson/workspace/EODAG/dev/eodag/eodag/resources/providers.yml
2025-02-11 15:39:44,387 eodag.config                     [INFO    ] Loading user configuration from: /home/anesson/.config/eodag/eodag.yml
2025-02-11 15:39:44,415 eodag.core                       [DEBUG   ] Opening product types index in /home/anesson/.config/eodag/.index
2025-02-11 15:39:44,422 eodag.core                       [DEBUG   ] Out-of-date product types index removed from /home/anesson/.config/eodag/.index
2025-02-11 15:39:44,423 eodag.core                       [DEBUG   ] Creating product types index in /home/anesson/.config/eodag/.index
2025-02-11 15:39:44,933 eodag.core                       [INFO    ] Locations configuration loaded from /home/anesson/.config/eodag/locations.yml
2025-02-11 15:39:44,933 eodag.config                     [INFO    ] Fetching external product types from https://cs-si.github.io/eodag/eodag/resources/ext_product_types.json
2025-02-11 15:39:46,010 eodag.core                       [DEBUG   ] Added 302 product types for cop_marine
2025-02-11 15:39:46,023 eodag.core                       [DEBUG   ] Added 3 product types for earth_search
2025-02-11 15:39:46,243 eodag.core                       [DEBUG   ] Added 63 product types for eumetsat_ds
2025-02-11 15:39:46,585 eodag.core                       [DEBUG   ] Added 107 product types for geodes
2025-02-11 15:39:47,054 eodag.core                       [DEBUG   ] Added 118 product types for planetary_computer
2025-02-11 15:39:47,087 eodag.core                       [DEBUG   ] Added 7 product types for usgs_satapi_aws
2025-02-11 15:39:51,154 eodag.core                       [DEBUG   ] Added 744 product types for wekeo_cmems
2025-02-11 15:39:51,157 eodag.core                       [DEBUG   ] Out-of-date product types index removed from /home/anesson/.config/eodag/.index
2025-02-11 15:39:51,157 eodag.core                       [DEBUG   ] Creating product types index in /home/anesson/.config/eodag/.index
2025-02-11 15:39:53,897 eodag.config                     [DEBUG   ] Loading configuration from /home/anesson/workspace/EODAG/dev/eodag/eodag/resources/providers.yml
2025-02-11 15:39:54,018 eodag.search.qssearch            [INFO    ] Fetching product types: https://hydroweb.next.theia-land.fr/api/v1/rs-catalog/stac/search/../collections
2025-02-11 15:39:56,895 eodag.core                       [DEBUG   ] Added 30 product types for hydroweb_next
2025-02-11 15:39:56,898 eodag.core                       [DEBUG   ] Out-of-date product types index removed from /home/anesson/.config/eodag/.index
2025-02-11 15:39:56,898 eodag.core                       [DEBUG   ] Creating product types index in /home/anesson/.config/eodag/.index
2025-02-11 15:39:59,932 eodag.auth.token_exchange        [DEBUG   ] Getting subject auth token
2025-02-11 15:39:59,933 eodag.auth.openid_connect        [DEBUG   ] access_token expired or not available yet, new token request
2025-02-11 15:39:59,933 eodag.auth.openid_connect        [DEBUG   ] Fetching access token from https://auth.destine.eu/realms/desp/protocol/openid-connect/token
2025-02-11 15:40:00,959 eodag.auth.token_exchange        [DEBUG   ] Getting target auth token
2025-02-11 15:40:01,325 eodag.search.qssearch            [INFO    ] Fetching product types: https://hda.data.destination-earth.eu/stac/collections
2025-02-11 15:40:01,326 eodag.auth.openid_connect        [DEBUG   ] PreparedRequest: {'method': 'GET', 'url': 'https://hda.data.destination-earth.eu/stac/collections', 'headers': {'User-Agent': 'eodag/3.1.0b2.dev32+gabec9a1d.d20250210', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Authorization': 'Bearer ***'}, '_cookies': <RequestsCookieJar[]>, 'body': None, 'hooks': {'response': []}, '_body_position': None}
2025-02-11 15:40:02,176 eodag.core                       [DEBUG   ] Added 2 product types for dedl
2025-02-11 15:40:02,179 eodag.core                       [DEBUG   ] Out-of-date product types index removed from /home/anesson/.config/eodag/.index
2025-02-11 15:40:02,179 eodag.core                       [DEBUG   ] Creating product types index in /home/anesson/.config/eodag/.index
Traceback (most recent call last):
  File "/home/anesson/workspace/EODAG/dev/eodag/docs/notebooks/api_user_guide/yyyymmdd_XXX_issue.py", line 142, in <module>
    extended_catalog = dag.list_product_types()
                       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/anesson/workspace/EODAG/dev/eodag/eodag/api/core.py", line 589, in list_product_types
    self.fetch_product_types_list(provider=provider)
  File "/home/anesson/workspace/EODAG/dev/eodag/eodag/api/core.py", line 710, in fetch_product_types_list
    if default_discovery_conf["result_type"] == "json" and isinstance(
       ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'result_type'
```
**Environment:**
 - Python version: 3.12.3
 - EODAG version: 3.1.0b2.dev32+gabec9a1d.d20250210

Hints from issue comments:
@gch-meoss: Hello,

I also have an issue with geodes and eodag.yml

the geodes_s3 provider is missing in eodag.yml but there is **two** geodes provides in the yaml file.

(eodag version used 3.1.0b2)@sbrunato: @gch-meoss this was fixed in `v3.1.0` with https://github.com/CS-SI/eodag/pull/1536.

You can remove your `eodag.yml` to make an up-to-date version of eodag recreate it, or manually edit it and rename one of the two `geodes` to `geodes_s3` and use the following authentication configuration template:
```yml
    auth:
        credentials:
            aws_access_key_id:
            aws_secret_access_key:
            aws_session_token:
```

Solution patch:
diff --git a/eodag/config.py b/eodag/config.py
index 0ceb1f1f7..db5ae7a06 100644
--- a/eodag/config.py
+++ b/eodag/config.py
@@ -779,6 +779,7 @@ def provider_config_init(
             and provider_config.search.type
             in [
                 "StacSearch",
+                "StacListAssets",
                 "StaticStacSearch",
             ]
         ):
diff --git a/eodag/resources/user_conf_template.yml b/eodag/resources/user_conf_template.yml
index 0d6c9e24a..5221bd2d0 100644
--- a/eodag/resources/user_conf_template.yml
+++ b/eodag/resources/user_conf_template.yml
@@ -157,7 +157,7 @@ geodes:
     download:
         extract:
         output_dir:
-geodes:
+geodes_s3:
     priority: # Lower value means lower priority (Default: 0)
     search: # Search parameters configuration
     auth:


Test patch:
diff --git a/tests/units/test_core.py b/tests/units/test_core.py
index 3b8faf950..9f5fdfd84 100644
--- a/tests/units/test_core.py
+++ b/tests/units/test_core.py
@@ -305,6 +305,7 @@ class TestCore(TestCoreBase):
             "dedl",
             "earth_search",
             "geodes",
+            "geodes_s3",
             "onda",
             "peps",
             "planetary_computer",
@@ -317,6 +318,7 @@ class TestCore(TestCoreBase):
             "creodias",
             "creodias_s3",
             "geodes",
+            "geodes_s3",
             "onda",
             "peps",
             "sara",
@@ -335,6 +337,7 @@ class TestCore(TestCoreBase):
             "creodias_s3",
             "dedl",
             "geodes",
+            "geodes_s3",
             "onda",
             "peps",
             "sara",
@@ -349,6 +352,7 @@ class TestCore(TestCoreBase):
             "earth_search",
             "earth_search_gcs",
             "geodes",
+            "geodes_s3",
             "onda",
             "peps",
             "sara",
@@ -368,7 +372,7 @@ class TestCore(TestCoreBase):
         ],
         "S2_MSI_L2AP": ["wekeo_main"],
         "S2_MSI_L2A_COG": ["earth_search_cog"],
-        "S2_MSI_L2A_MAJA": ["geodes", "theia"],
+        "S2_MSI_L2A_MAJA": ["geodes", "geodes_s3", "theia"],
         "S2_MSI_L2B_MAJA_SNOW": ["theia"],
         "S2_MSI_L2B_MAJA_WATER": ["theia"],
         "S2_MSI_L3A_WASP": ["theia"],
@@ -635,6 +639,7 @@ class TestCore(TestCoreBase):
         "ecmwf",
         "eumetsat_ds",
         "geodes",
+        "geodes_s3",
         "hydroweb_next",
         "meteoblue",
         "onda",
@@ -1828,6 +1833,16 @@ def test_available_sortables(self):
                     "cloudCover",
                 ],
             },
+            "geodes_s3": {
+                "max_sort_params": None,
+                "sortables": [
+                    "id",
+                    "startTimeFromAscendingNode",
+                    "completionTimeFromAscendingNode",
+                    "platformSerialIdentifier",
+                    "cloudCover",
+                ],
+            },
             "hydroweb_next": {
                 "sortables": [
                     "id",