Skip to content

oras push --artifact-platform is not compatible with oras pull --platform and similar commands #1517

Description

@Wwwsylvia

What happened in your environment?

The PR #1500 introduced a new --artifact-platform option to the oras push command, which adds platform information to the artifact configuration using the media type "application/vnd.unknown.config.v1+json" by default.

However, this implementation of oras push --artifact-platform is incompatible with other commands that provide the --platform option, such as oras pull --platform, oras manifest fetch-config --platform, and oras copy --platform.

Symptom

For example, if one pushes an artifact with platform metadata like this:

oras push localhost:5000/myartifact:v1 blob --artifact-platform linux/amd64

and then pulls it specifying the platform as well:

oras pull localhost:5000/myartifact:v1 --platform linux/amd64

They would get this error message:

Error: fail to recognize platform from unknown config application/vnd.unknown.config.v1+json: expect application/vnd.oci.image.config.v1+json

Root Cause

This is because the oras-go backing library only extracts platform information from the image config media type "application/vnd.oci.image.config.v1+json" and throws errors for any other config media type.

Workaround

To temporarily address this issue, we can use "application/vnd.oci.image.config.v1+json" as the default config media type. While this solution is not ideal and introduces other problems, it serves as a workaround to enable the end-to-end workflow. Ultimately, we may need to reconsider the design for adding the platform information.

What did you expect to happen?

No response

How can we reproduce it?

  1. Push an artifact with platform information:

    oras push localhost:5000/myartifact:v1 blob --artifact-platform linux/amd64
  2. Pull the same artifact specifying the platform:

    oras pull localhost:5000/myartifact:v1 --platform linux/amd64

What is the version of your ORAS CLI?

Version: 1.2.0+unreleased
Go version: go1.23.0
Git commit: 97cb376
Git tree state: clean

What is your OS environment?

Ubuntu 22.04.1

Are you willing to submit PRs to fix it?

  • Yes, I am willing to fix it.

Activity

  1. added
    bug
    triage
    on Oct 25, 2024
  2. removed
    triage
    on Oct 29, 2024
  3. added this to the v1.3.0 milestone on Oct 29, 2024
  4. qweeah commented on Oct 29, 2024

    @qweeah
    Contributor

    Checked the oras-go function that does the platform matching, sounds like --artifact-type should not be used with --aritfact-platform for when image spec is set tov1.0

    ➜  oras git:(main) ✗ ./bin/linux/amd64/oras push localhost:5000/test:config-type --artifact-platform linux/amd64 --artifact-type billy/test --image-spec v1.0
    ✓ Exists    billy/test                                                                                                         37/37  B 100.00%     0s
      └─ sha256:9d99a75171aea000c711b34c0e5e3f28d3d537dd99d110eafbfbc2bd8e52c2bf
    ✓ Uploaded  application/vnd.oci.image.manifest.v1+json                                                                       291/291  B 100.00%     0s
      └─ sha256:42f833fb2750fab31688457d69c57e5a7f4b6dbd13c8bffbdbd2e5a56bdf6e87
    Pushed [registry] localhost:5000/test:config-type
    ArtifactType: billy/test
    Digest: sha256:42f833fb2750fab31688457d69c57e5a7f4b6dbd13c8bffbdbd2e5a56bdf6e87
    ➜  oras git:(main) ✗ ./bin/linux/amd64/oras pull localhost:5000/test:config-type --platform linux/amd64
    Error: fail to recognize platform from unknown config billy/test: expect application/vnd.oci.image.config.v1+json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions