mirror of
https://github.com/apple/container.git
synced 2026-09-13 03:05:42 +00:00
The `mediaType` field in the `Index` struct was defined as a required field, but according to the [OCI Image Index Specification](https://github.com/opencontainers/image-spec/blob/main/image-index.md), this field is optional. This caused failures when loading OCI archives where the `index.json` omits the top-level `mediaType` field, which is valid per the spec. Tools like skopeo can generate such archives. ## Error before fix ``` keyNotFound(CodingKeys(stringValue: "mediaType", intValue: nil)) ``` ## Changes - Changed `Index.mediaType` from `String` to `String?` - Updated initializer to accept optional `mediaType` parameter - Added comment documenting that field is optional per OCI spec ## Testing Verified that OCI archives without a top-level `mediaType` field in `index.json` now load successfully. Fixes https://github.com/apple/container/issues/330