Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] index or manifest list without the OPTIONAL field platform cause panic #692

Closed
soumiksamanta opened this issue Jan 24, 2024 · 1 comment · Fixed by #695
Closed
Labels
bug Something isn't working
Milestone

Comments

@soumiksamanta
Copy link

soumiksamanta commented Jan 24, 2024

As per the Image Spec, Platform field is optional.
However the below code will cause a panic at https://github.com/oras-project/oras-go/blob/main/internal/platform/platform.go#L40 if there is no platform in the manifest list.

for _, m := range manifests {
if Match(m.Platform, p) {
return m, nil
}
}

panic({0x1a09720, 0x2ccc1f0}) │
/usr/local/go/src/runtime/panic.go:884 +0x213 │
oras.land/oras-go/v2/internal/platform.Match(0x0, 0xc000eecd20) │
/home/dev/ws/build/.cache/go-mod/pkg/mod/oras.land/oras-go/v2@v2.3.1/internal/platform/platform.go:41 +0x39 │
oras.land/oras-go/v2/internal/platform.SelectManifest({_, }, {, }, {{0xc0006272f0, 0x27}, {0xc0007b0f50, 0x47}, 0xf68, {0x0, ...}, ...}, ...) │
/home/dev/ws/build/.cache/go-mod/pkg/mod/oras.land/oras-go/v2@v2.3.1/internal/platform/platform.go:88 +0x68b │
oras.land/oras-go/v2.(*CopyOptions).WithTargetPlatform.func1({
, }, {, }, {{0xc0006272f0, 0x27}, {0xc0007b0f50, 0x47}, 0xf68, {0x0, ...}, ...}) │
/home/dev/ws/build/.cache/go-mod/pkg/mod/oras.land/oras-go/v2@v2.3.1/copy.go:78 +0x23e │
oras.land/oras-go/v2.Copy({0x1f2ca58, 0xc00005c058}, {0x1f2b750, 0xc0009980b0}, {0xc0003c7990, 0x6}, {
, _}, {0x0, 0x0}, ...) │
/home/dev/ws/build/.cache/go-mod/pkg/mod/oras.land/oras-go/v2@v2.3.1/copy.go:143 +0x430

@Wwwsylvia
Copy link
Member

This is indeed a bug. Thank you @soumiksamanta for catching this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
2 participants