Skip to content
Open
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
10 changes: 9 additions & 1 deletion openeo_driver/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,7 @@ def job_results_canonical_url() -> str:
job_id=job_id, user_id=user_id
)
result_assets = result_metadata.assets
result_items = result_metadata.items
providers = result_metadata.providers

# TODO: remove feature toggle, during refactoring for openeo-geopyspark-driver#440
Expand Down Expand Up @@ -1187,10 +1188,16 @@ def job_result_item_url(item_id, is11 = False) -> str:


if len(result_metadata.items) > 0 :
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if len(result_metadata.items) > 0 :
if result_metadata.items:

I would take the opportunity to replace this as it it shorter, safer and expresses the intent better.

assets = {
item_key + "_" + asset_key: asset_metadata
for item_key, item_metadata in result_items.items()
for asset_key, asset_metadata in item_metadata.get("assets").items()
}
Comment on lines 1190 to +1195

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Build STAC 1.1 assets without URL signing

When items are present the collection’s assets are now rebuilt straight from result_metadata.items (item_metadata.get("assets").items()) without calling _asset_object. In the STAC 1.0 path each asset is wrapped by _asset_object, which injects signed/absolute hrefs and honours the asset flag. The new branch therefore returns raw backend metadata for STAC 1.1, which can omit href entirely or contain unsigned/internal paths, breaking download links for backends that rely on asset_url.build_url or URL signing. This regression only manifests for jobs producing STAC 1.1 items and makes the collection response unusable for clients expecting valid asset URLs.

Useful? React with 👍 / 👎.

for item_id in result_metadata.items.keys():
links.append(
{"rel": "item", "href": job_result_item_url(item_id=item_id, is11=True), "type": stac_item_media_type}
)
stac_version = "1.1.0"
else:

for filename, metadata in result_assets.items():
Expand All @@ -1206,11 +1213,12 @@ def job_result_item_url(item_id, is11 = False) -> str:
links.append(
{"rel": "item", "href": job_result_item_url(item_id=filename), "type": "application/json"}
)
stac_version = "1.0.0"

result = dict_no_none(
{
"type": "Collection",
"stac_version": "1.0.0",
"stac_version": stac_version,
"stac_extensions": [
STAC_EXTENSION.EO_V110,
STAC_EXTENSION.FILEINFO,
Expand Down
3 changes: 3 additions & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2930,6 +2930,9 @@ def test_get_job_results_from_stac_1_1_items(self, api110, backend_config_overri

resp = api110.get(f"/jobs/{job_id}/results", headers=self.AUTH_HEADER).assert_status_code(200)

assert "assets" in resp.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test the actual value of this assets property.

assert resp.json.get("stac_version") == "1.1.0"

item_links = [link for link in resp.json["links"] if link["rel"] == "item"]
assert len(item_links) == 1, "expected exactly one item link in STAC Collection"

Expand Down