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

oras manifest fetch will panic if --platform flag is used on certain index/manifest list #1252

Closed
1 task
qweeah opened this issue Jan 25, 2024 · 1 comment
Closed
1 task
Assignees
Labels
bug Something isn't working
Milestone

Comments

@qweeah
Copy link
Contributor

qweeah commented Jan 25, 2024

What happened in your environment?

If I baked an index containing a manifest without platform information and tried to use oras manifest fetch --platform, then the execution will painc.

What did you expect to happen?

The execution should fail with errors like

> oras manifest fetch --descriptor localhost:7000/command/images:multi1 --platform test/platform
Error: failed to find "localhost:7000/command/images:multi1": sha256:a75baa86dca530232c82eb68a5e97506aa85356e0ee5f1df852a01a9916fdca8: not found: no matching manifest was found in the manifest list

How can we reproduce it?

> cat test.platform.json
{"mediaType":"application/vnd.oci.image.index.v1+json","schemaVersion":2,"manifests":[{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:9d84a5716c66a1d1b9c13f8ed157ba7d1edfe7f9b8766728b8a1f25c0d9c14c1","size":458},{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:4f93460061882467e6fb3b772dc6ab72130d9ac1906aed2fc7589a5cd145433c","size":458,"platform":{"architecture":"arm64","os":"linux"}},{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:58efe73e78fe043ca31b89007a025c594ce12aa7e6da27d21c7b14b50112e255","size":458,"platform":{"architecture":"arm","os":"linux","variant":"v7"}}]}
> oras manifest push localhost:7000/command/images:multi1 test.platform.json
Pushed [registry] localhost:7000/command/images:multi1
Digest: sha256:a75baa86dca530232c82eb68a5e97506aa85356e0ee5f1df852a01a9916fdca8
> oras manifest fetch --descriptor localhost:7000/command/images:multi1 --platform test/platform
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x5e308d]

goroutine 1 [running]:
oras.land/oras-go/v2/internal/platform.Match(0x0, 0xc00009c900)
        /home/runner/go/pkg/mod/oras.land/oras-go/[email protected]/internal/platform/platform.go:41 +0x2d
oras.land/oras-go/v2/internal/platform.SelectManifest({_, _}, {_, _}, {{0xc00002e0c0, 0x27}, {0xc000032050, 0x47}, 0x292, {0x0, ...}, ...}, ...)
        /home/runner/go/pkg/mod/oras.land/oras-go/[email protected]/internal/platform/platform.go:88 +0x66b
oras.land/oras-go/v2.resolve({0x9782c8, 0xc00020eab0}, {0x977600?, 0xc0000b4370?}, 0x0, {0x7ffd113505b6, 0x6}, {0xc00009c900?, 0xc0001df8c8?})
        /home/runner/go/pkg/mod/oras.land/oras-go/[email protected]/content.go:233 +0x5a6
oras.land/oras-go/v2.Resolve({0x9782c8?, 0xc00020eab0?}, {0x977600?, 0xc0000b4370?}, {0x7ffd113505b6?, 0x8?}, {0xc00009c900?, 0x49fdbc?})
        /home/runner/go/pkg/mod/oras.land/oras-go/[email protected]/content.go:196 +0xc9
oras.land/oras/cmd/oras/root/manifest.fetchManifest({_, _}, {{{0x0, 0x0}}, {0x0, 0x0}, {0x1}, {{0x7ffd113505c8, 0xd}, 0xc00009c900}, ...})
        /home/runner/work/oras/oras/cmd/oras/root/manifest/fetch.go:118 +0x27e
oras.land/oras/cmd/oras/root/manifest.fetchCmd.func2(0xc0000b1500?, {0xc0000a0b40?, 0x4?, 0x8b37c3?})
        /home/runner/work/oras/oras/cmd/oras/root/manifest/fetch.go:82 +0x5b
github.com/spf13/cobra.(*Command).execute(0xc0001fb500, {0xc0000a0b00, 0x4, 0x4})
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:940 +0x87c
github.com/spf13/cobra.(*Command).ExecuteC(0xc000128300)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:992
github.com/spf13/cobra.(*Command).ExecuteContext(0x978290?, {0x978450?, 0xc0000a05c0?})
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:985 +0x47
main.main()
        /home/runner/work/oras/oras/cmd/oras/main.go:29 +0x96

What is the version of your ORAS CLI?

v1.1.0

What is your OS environment?

20.04

Are you willing to submit PRs to fix it?

  • Yes, I am willing to fix it.
@qweeah qweeah added bug Something isn't working triage New issues or PRs to be acknowledged by maintainers labels Jan 25, 2024
@qweeah qweeah added this to the v1.2.0 milestone Jan 25, 2024
@qweeah qweeah changed the title oras manifest fetch will panic --platform flag is used on certain index/manifest list oras manifest fetch will panic if --platform flag is used on certain index/manifest list Jan 25, 2024
@qweeah
Copy link
Contributor Author

qweeah commented Jan 25, 2024

Related to oras-project/oras-go#692

@yizha1 yizha1 removed the triage New issues or PRs to be acknowledged by maintainers label Jan 30, 2024
@shizhMSFT shizhMSFT assigned FeynmanZhou and qweeah and unassigned FeynmanZhou Mar 12, 2024
@qweeah qweeah closed this as completed Mar 12, 2024
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
None yet
Development

No branches or pull requests

3 participants