You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: tracked targets always claim registry.Mounter and panic on non-remote targets #2278
graphTarget in cmd/oras/internal/display/status/track/target.go always defines Mount:
// Mount mounts a blob from a specified repository. This method is invoked only// by the `*remote.Repository` target.func (t*graphTarget) Mount(ctx context.Context, desc ocispec.Descriptor, fromRepostring, getContentfunc() (io.ReadCloser, error)) error {
mounter:=t.GraphTarget.(registry.Mounter)
returnmounter.Mount(ctx, desc, fromRepo, getContent)
}
As a result, every tracked target satisfies registry.Mounter, including OCI-layout and other non-remote targets. oras-go decides whether to mount by type-asserting the destination for registry.Mounter. A wrapped non-remote target therefore claims mount support, and if a mount is ever attempted the unchecked assertion panics rather than returning an error or falling back to copy.
Today this is masked because cp only sets MountFrom when both sides are remote (getMountPoint). That depends on a caller-side invariant, and any future caller (backup/restore, attach, a library refactor) that sets MountFrom against a tracked OCI-layout target would crash.
Proposed fix
Expose Mount only when the wrapped target supports it. referenceGraphTarget already does this for PushReference:
keep graphTarget without Mount
add a mounterGraphTarget wrapper returned by NewTarget only when gt.(registry.Mounter) succeeds
alternatively, use a checked assertion that returns errdef.ErrUnsupported, so oras-go falls back to copy
Add a unit test that wraps an oci.Store and asserts _, ok := tracked.(registry.Mounter); !ok.
oras-go v3 note
v3 keeps the same registry.Mounter type-assertion contract (registry/interfaces.go), and the code is unchanged on the v3 migration branch (#2002).
I’d like to work on this. I’ll add a regression that checks tracked OCI-layout targets do not advertise registry.Mounter, keep mounting available for remote targets, then run the affected Go package tests and lint.
For whoever picks this up: the panic is reachable today, not only in theory. oras cp --force wraps the destination in contentutil.TraversingTarget after getMountPoint has set up MountFrom on the raw repository. The tracked graph target still claims registry.Mounter, so the type assertion in Mount fails. Against a local registry:2, run from a terminal (the TTY path uses the tracked target):
oras cp --force localhost:5000/src:v1 localhost:5000/dst:v1
panic: interface conversion: *contentutil.TraversingTarget is not registry.Mounter: missing method Mount
Without --force, or without a TTY, it works. That case might be worth covering in the regression test too.
Activity
kocaemre commentedon Oct 23, 2026
I’d like to work on this. I’ll add a regression that checks tracked OCI-layout targets do not advertise registry.Mounter, keep mounting available for remote targets, then run the affected Go package tests and lint.
wleeaf commentedon Oct 23, 2026
For whoever picks this up: the panic is reachable today, not only in theory.
oras cp --forcewraps the destination incontentutil.TraversingTargetaftergetMountPointhas set upMountFromon the raw repository. The tracked graph target still claimsregistry.Mounter, so the type assertion inMountfails. Against a localregistry:2, run from a terminal (the TTY path uses the tracked target):Without
--force, or without a TTY, it works. That case might be worth covering in the regression test too.