Skip to content

fix(oci): render arm64 platform description without redundant v8 - #783

Open
Halvanhelv wants to merge 1 commit into
apple:mainfrom
Halvanhelv:fix/platform-description-canonical-arm64
Open

fix(oci): render arm64 platform description without redundant v8#783
Halvanhelv wants to merge 1 commit into
apple:mainfrom
Halvanhelv:fix/platform-description-canonical-arm64

Conversation

@Halvanhelv

Copy link
Copy Markdown

Summary

Platform.description renders the same arm64 platform two different ways
depending on how the value was constructed:

Platform(arch: "arm64", os: "linux", variant: nil).description  // "linux/arm64"
Platform(arch: "arm64", os: "linux", variant: "v8").description // "linux/arm64/v8"

These are the same platform — ==, hash(into:), and Set membership
already treat an arm64 nil variant as equivalent to "v8" — yet they
serialize differently, so a single platform drifts between linux/arm64 and
linux/arm64/v8 across stages of one build (apple/container#1542).

Relation to #764

#764 fixed the Hashable side of this: it stopped hash(into:) from using
description and canonicalized arm64 nilv8 in the hash. That worked
around the inconsistent description but did not fix it — its own summary
names description (linux/arm64 vs linux/arm64/v8) as the root cause.
This PR fixes that remaining gap at the source.

Change

Omit the redundant v8 variant for arm64 when rendering description, so
equal arm64 platforms always describe as linux/arm64 — matching how Docker
and containerd display the platform. Other variants (arm/v7) and
architectures (amd64) are unaffected.

Only the rendered description changes. The stored variant and the
Codable encoding are untouched, so OCI content digests remain stable.

Testing

Added OCIPlatformTests cases for description consistency (equal arm64
platforms describe identically; arm64/v8 renders as linux/arm64;
arm/v7 and amd64 preserved). swift test --filter ContainerizationOCITests
passes (55 tests); swift format lint --strict clean.

Closes apple/container#1542 (normalization-consistency aspect).

@Halvanhelv
Halvanhelv force-pushed the fix/platform-description-canonical-arm64 branch from 1e8f0c7 to 7eb0c7d Compare June 27, 2026 23:09
@adityaramani

Copy link
Copy Markdown
Contributor

Thanks for the change! Can you please rebase the change before we merge

`Platform.description` rendered the same arm64 platform two different ways
depending on how the value was constructed: `linux/arm64` when the variant
was `nil`, and `linux/arm64/v8` when the variant was set to `"v8"`. These
are the same platform — `==`, `hash`, and Set membership already treat an
arm64 `nil` variant as equivalent to `"v8"` — so two equal values produced
different descriptions and drifted between `arm64` and `arm64/v8` across
stages of a single build (apple/container#1542).

Omit the redundant `v8` variant for arm64 so equal platforms always
describe as `linux/arm64`, matching how Docker and containerd display it.
Only the rendered description changes; the stored variant and Codable
encoding are untouched, so OCI content digests remain stable.
@Halvanhelv
Halvanhelv force-pushed the fix/platform-description-canonical-arm64 branch from 7eb0c7d to 05af1ac Compare August 6, 2026 19:39
@Halvanhelv

Copy link
Copy Markdown
Author

Thanks for the change! Can you please rebase the change before we merge

Done

@adityaramani adityaramani left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Only nit I have is do we need to remove the references to the issues in the code. Will wait for another maintainer to weigh in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Inconsistent platform-string normalization (arm64arm64/v8) within a single build

2 participants