Note: This issue is the assessment of Claude Code. It seems plausible to me, but I'm not sure I understand STAC enough to know if it's got it right. I won't feel bad if you just say "this is incorrect" and close the issue. 🙃
Summary
read_icechunk in xpystac/_icechunk.py retrieves storage:schemes from
asset.owner.extra_fields:
storage_schemes = collection.extra_fields["storage:schemes"]
This works when the parent object is a pystac.Collection with storage:schemes
in extra_fields (e.g. the pattern shown in the
dse-virtual-zarr-workshop notebook).
However, when the parent is a pystac.Item, the STAC storage extension
spec places storage:schemes inside
item.properties, not extra_fields. In that case extra_fields won't contain
the key and the lookup raises a KeyError.
Suggested fix
Fall back to asset.owner.properties when extra_fields doesn't contain
storage:schemes:
owner = asset.owner
storage_schemes = owner.extra_fields.get("storage:schemes") or owner.properties.get("storage:schemes", {})
This would make xpystac work with both Collection-based catalogs (current pattern)
and Item-based catalogs (STAC spec–conformant placement of storage:schemes in
properties).
Workaround
Until this is fixed, callers using Item-based catalogs can copy the field manually
before opening:
item.extra_fields["storage:schemes"] = item.properties.get("storage:schemes", {})
asset = next(a for a in item.assets.values() if a.media_type == "application/vnd.zarr+icechunk")
ds = xr.open_dataset(asset, engine="stac")
Note: This issue is the assessment of Claude Code. It seems plausible to me, but I'm not sure I understand STAC enough to know if it's got it right. I won't feel bad if you just say "this is incorrect" and close the issue. 🙃
Summary
read_icechunkinxpystac/_icechunk.pyretrievesstorage:schemesfromasset.owner.extra_fields:This works when the parent object is a
pystac.Collectionwithstorage:schemesin
extra_fields(e.g. the pattern shown in thedse-virtual-zarr-workshop notebook).
However, when the parent is a
pystac.Item, the STAC storage extensionspec places
storage:schemesinsideitem.properties, notextra_fields. In that caseextra_fieldswon't containthe key and the lookup raises a
KeyError.Suggested fix
Fall back to
asset.owner.propertieswhenextra_fieldsdoesn't containstorage:schemes:This would make xpystac work with both Collection-based catalogs (current pattern)
and Item-based catalogs (STAC spec–conformant placement of
storage:schemesinproperties).Workaround
Until this is fixed, callers using Item-based catalogs can copy the field manually
before opening: