Skip to content

read_icechunk falls back to extra_fields but misses storage:schemes in item.properties #65

@rsignell

Description

@rsignell

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")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions