Repository navigation
Description
What happened in your environment?
Hey Peeps! :)
We found an interesting conundrum when dealing with oci layers and outlines on disk with --oci-layout.
It looks like, the parsing of the Ref on the cli for oras doesn't follow how a tag could look like? A tag accepts an absolute reference value but here it needs to be relative.
What am I talking about?
I'm talking about this function:
oras/cmd/oras/internal/option/target.go
Line 133 in 6f04cf0
| func (target *Target) parseOCILayoutReference() error { |
And here is the tag ref grammar: https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
The reproducing steps:
oras cp --to-oci-layout ghcr.io/stefanprodan/podinfo:6.8.0 ghcr.io/stefanprodan/podinfo:6.8.0
oras manifest fetch --oci-layout ./:6.8.0
# edit the `index.json` such that the annotation for index is the full ref: annotations: ["org.opencontainers.image.ref.name":"ghcr.io/stefanprodan/podinfo:6.8.0"]
oras manifest fetch --oci-layout ./:ghcr.io/stefanprodan/podinfo:6.8.0 # this now errors even though technically, it should be correct
➜ oras manifest fetch --oci-layout ./:ghcr.io/stefanprodan/podinfo:6.8.0
Error: invalid argument "./:ghcr.io/stefanprodan/podinfo:6.8.0": failed to find path "./:ghcr.io/stefanprodan/podinfo": stat ./:ghcr.io/stefanprodan/podinfo: no such file or directory
throws errors because it's biting off the end of the absolute path and then looks for that directory.
It's worth mentioning that the library does work. So there is some weirdness somewhere. :)
If this is indeed a discrepancy, we are fully committed to provide a fix as well. So we are going to do the work. :)
Thanks 🙇
What did you expect to happen?
Parsing of the reference to be working with relative and absolute path as well.
How can we reproduce it?
oras cp --to-oci-layout ghcr.io/stefanprodan/podinfo:6.8.0 ghcr.io/stefanprodan/podinfo:6.8.0
oras manifest fetch --oci-layout ./:6.8.0
# edit the `index.json` such that the annotation for index is the full ref: annotations: ["org.opencontainers.image.ref.name":"ghcr.io/stefanprodan/podinfo:6.8.0"]
oras manifest fetch --oci-layout ./:ghcr.io/stefanprodan/podinfo:6.8.0 # this now errors even though technically, it should be correct
➜ oras manifest fetch --oci-layout ./:ghcr.io/stefanprodan/podinfo:6.8.0
Error: invalid argument "./:ghcr.io/stefanprodan/podinfo:6.8.0": failed to find path "./:ghcr.io/stefanprodan/podinfo": stat ./:ghcr.io/stefanprodan/podinfo: no such file or directory
What is the version of your ORAS CLI?
➜ oras version
Version: 1.2.2+Homebrew
Go version: go1.23.4
What is your OS environment?
osx, linux
Are you willing to submit PRs to fix it?
- Yes, I am willing to fix it.
Activity
TerryHowe commentedon Apr 3, 2025
Why not?
Skarlso commentedon Apr 3, 2025
TerryHowe commentedon Apr 3, 2025
I was confused on why you had
:in the path and your instructions would not put that in the path.After I modify the
index.json, I getbut not the "failed to find path" that you got. The error message I got is not very helpful, because it is probably something like a mismatch on expected reference.
TerryHowe commentedon Apr 3, 2025
What is the reason to modify the
index.json? Both references should be there:Skarlso commentedon Apr 3, 2025
What do you mean by "should be there"? Do you mean that oras fetch should have put in both...? Because right now, that's all the index.json file is:
{ "schemaVersion": 2, "manifests": [ { "mediaType": "application/vnd.oci.image.index.v1+json", "digest": "sha256:6c1975b871efb327528c84d46d38e6dd7906eecee6402bc270eeb7f1b1a506df", "size": 2385, "annotations": { "org.opencontainers.image.ref.name": "6.8.0" } }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:365b1952433cbb4cf0e8bea4bb9b243096f6f987f7e8b32ae0e3f5a480a33650", "size": 840, "annotations": { "vnd.docker.reference.digest": "sha256:214be3e0fcce3be28e948e838eea34d6e3d9b24ce0689d7b879477a5d4b709d1", "vnd.docker.reference.type": "attestation-manifest" }, "platform": { "architecture": "unknown", "os": "unknown" } }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:4468906882c4ff094af439835d5a76719cb6feea98bb8ea087fc8964f3568610", "size": 840, "annotations": { "vnd.docker.reference.digest": "sha256:076337b0f03bf33430505b37898390a6090efea255222a647d10a05ed2926996", "vnd.docker.reference.type": "attestation-manifest" }, "platform": { "architecture": "unknown", "os": "unknown" } }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:47190298cb07dbb845dd29445b827dbe4a1cb4d92157182343e40c8b60319ffb", "size": 840, "annotations": { "vnd.docker.reference.digest": "sha256:e17bf402cd8ff41a322d12dc013678bf03e3558909c5a3a32388cbe157292f13", "vnd.docker.reference.type": "attestation-manifest" }, "platform": { "architecture": "unknown", "os": "unknown" } }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:076337b0f03bf33430505b37898390a6090efea255222a647d10a05ed2926996", "size": 1627, "platform": { "architecture": "arm", "os": "linux", "variant": "v7" } }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:214be3e0fcce3be28e948e838eea34d6e3d9b24ce0689d7b879477a5d4b709d1", "size": 1627, "platform": { "architecture": "amd64", "os": "linux" } }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:e17bf402cd8ff41a322d12dc013678bf03e3558909c5a3a32388cbe157292f13", "size": 1625, "platform": { "architecture": "arm64", "os": "linux" } } ] }wangxiaoxuan273 commentedon Apr 8, 2025
I can reproduce the error. It is caused by
oras-clionly treating the string after the last:as tag. It does not consider cases in which a tag contains:. But this may be tricky to fix, as directory path is also allowed to have:.Skarlso commentedon Apr 8, 2025
Nice, thanks very much.
Wwwsylvia commentedon Apr 10, 2025
After running
oras cp --to-oci-layout ghcr.io/stefanprodan/podinfo:6.8.0 ghcr.io/stefanprodan/podinfo:6.8.0, I got the following directory structure:In this structure, the root directory of the OCI layout is
ghcr.io/stefanprodan/podinfo, withghcr.ioandstefanprodanas parent directories.With this, I'm able to get the manifest content by running:
or
Differences between the two commands:
:as the tag and everything before:as the path to the OCI layout root.6.8.0as the target tag and the parameter of--oci-layout-pathas the OCI layout root.To check the index.json, I run:
The output was:
{ "schemaVersion": 2, "mediaType": "application/vnd.oci.image.index.v1+json", "manifests": [ { "mediaType": "application/vnd.oci.image.index.v1+json", "digest": "sha256:6c1975b871efb327528c84d46d38e6dd7906eecee6402bc270eeb7f1b1a506df", "size": 2385, "annotations": { "org.opencontainers.image.ref.name": "6.8.0" } }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:4468906882c4ff094af439835d5a76719cb6feea98bb8ea087fc8964f3568610", "size": 840, "annotations": { "vnd.docker.reference.digest": "sha256:076337b0f03bf33430505b37898390a6090efea255222a647d10a05ed2926996", "vnd.docker.reference.type": "attestation-manifest" }, "platform": { "architecture": "unknown", "os": "unknown" } }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:47190298cb07dbb845dd29445b827dbe4a1cb4d92157182343e40c8b60319ffb", "size": 840, "annotations": { "vnd.docker.reference.digest": "sha256:e17bf402cd8ff41a322d12dc013678bf03e3558909c5a3a32388cbe157292f13", "vnd.docker.reference.type": "attestation-manifest" }, "platform": { "architecture": "unknown", "os": "unknown" } }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:e17bf402cd8ff41a322d12dc013678bf03e3558909c5a3a32388cbe157292f13", "size": 1625, "platform": { "architecture": "arm64", "os": "linux" } }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:214be3e0fcce3be28e948e838eea34d6e3d9b24ce0689d7b879477a5d4b709d1", "size": 1627, "platform": { "architecture": "amd64", "os": "linux" } }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:076337b0f03bf33430505b37898390a6090efea255222a647d10a05ed2926996", "size": 1627, "platform": { "architecture": "arm", "os": "linux", "variant": "v7" } }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:365b1952433cbb4cf0e8bea4bb9b243096f6f987f7e8b32ae0e3f5a480a33650", "size": 840, "annotations": { "vnd.docker.reference.digest": "sha256:214be3e0fcce3be28e948e838eea34d6e3d9b24ce0689d7b879477a5d4b709d1", "vnd.docker.reference.type": "attestation-manifest" }, "platform": { "architecture": "unknown", "os": "unknown" } } ] }To use the full reference
ghcr.io/stefanprodan/podinfo:6.8.0as a tag, I run:The
index.jsonwill then become:{ "schemaVersion": 2, "mediaType": "application/vnd.oci.image.index.v1+json", "manifests": [ { "mediaType": "application/vnd.oci.image.index.v1+json", "digest": "sha256:6c1975b871efb327528c84d46d38e6dd7906eecee6402bc270eeb7f1b1a506df", "size": 2385, "annotations": { "org.opencontainers.image.ref.name": "ghcr.io/stefanprodan/podinfo:6.8.0" } }, { "mediaType": "application/vnd.oci.image.index.v1+json", "digest": "sha256:6c1975b871efb327528c84d46d38e6dd7906eecee6402bc270eeb7f1b1a506df", "size": 2385, "annotations": { "org.opencontainers.image.ref.name": "6.8.0" } }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:076337b0f03bf33430505b37898390a6090efea255222a647d10a05ed2926996", "size": 1627, "platform": { "architecture": "arm", "os": "linux", "variant": "v7" } }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:365b1952433cbb4cf0e8bea4bb9b243096f6f987f7e8b32ae0e3f5a480a33650", "size": 840, "annotations": { "vnd.docker.reference.digest": "sha256:214be3e0fcce3be28e948e838eea34d6e3d9b24ce0689d7b879477a5d4b709d1", "vnd.docker.reference.type": "attestation-manifest" }, "platform": { "architecture": "unknown", "os": "unknown" } }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:4468906882c4ff094af439835d5a76719cb6feea98bb8ea087fc8964f3568610", "size": 840, "annotations": { "vnd.docker.reference.digest": "sha256:076337b0f03bf33430505b37898390a6090efea255222a647d10a05ed2926996", "vnd.docker.reference.type": "attestation-manifest" }, "platform": { "architecture": "unknown", "os": "unknown" } }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:47190298cb07dbb845dd29445b827dbe4a1cb4d92157182343e40c8b60319ffb", "size": 840, "annotations": { "vnd.docker.reference.digest": "sha256:e17bf402cd8ff41a322d12dc013678bf03e3558909c5a3a32388cbe157292f13", "vnd.docker.reference.type": "attestation-manifest" }, "platform": { "architecture": "unknown", "os": "unknown" } }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:e17bf402cd8ff41a322d12dc013678bf03e3558909c5a3a32388cbe157292f13", "size": 1625, "platform": { "architecture": "arm64", "os": "linux" } }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:214be3e0fcce3be28e948e838eea34d6e3d9b24ce0689d7b879477a5d4b709d1", "size": 1627, "platform": { "architecture": "amd64", "os": "linux" } } ] }This allows me to get the same manifest by running:
@Skarlso Does the same flow work for you? 🤔
Skarlso commentedon Apr 10, 2025
Problem is that we are unsure if we are even using things appropriately. That folder structure is actually not OCI compliant, right? It's just something ORAS did. The library store interface only works with a root in the filesystem. But can't handle multiple roots.
https://github.com/oras-project/oras-go/blob/main/content/oci/readonlyoci.go and https://github.com/oras-project/oras-go/blob/main/content/file/file.go do not support this behavior unless we misunderstand how we are supposed to use it together with this file structure.
If you have a better example or a guide in how to do that, we are also open to that. Maybe we are doing something wrong. :)
Wwwsylvia commentedon Apr 11, 2025
For the command:
The target
ghcr.io/stefanprodan/podinfo:6.8.0is interpreted with everything before:as the path and everything after:as the target tag. This is why a directory structure is created. Essentially,ghcr.io/stefanprodan/podinfois just a path to the rootpodinfoand doesn't have any special meaning—it's similar tofoo/bar/podinfoor./podinfo.To avoid this, you can use a simpler path for the OCI layout folder:
Here, the target OCI root is
podinfoand the target tag is6.8.0.Alternatively, you can use:
In this case, the target OCI root is
podinfoand the target tag is the full referenceghcr.io/stefanprodan/podinfo:6.8.0.Did this answer your question? Are you using CLI or SDK? 🤔
wangxiaoxuan273 commentedon May 19, 2025
Basically the same issue: #1505
github-actions commentedon Jul 19, 2025
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Skarlso commentedon Jul 30, 2025
Ah great. :D I think that fixes our use case as well. I'm so sorry for being absent on this bug. 🙇 Not very polite from me. :/
github-actions commentedon Sep 30, 2025
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.
github-actions commentedon Oct 30, 2025
This issue was closed because it has been stalled for 30 days with no activity.
github-actions commentedon Dec 30, 2025
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.
github-actions commentedon Jan 29, 2026
This issue was closed because it has been stalled for 30 days with no activity.