{"record":{"id":"0dc30a1be42e91ce","repo":"docker/cli","slug":"failed-to-mount-blob-s-to-s-w","errorCode":null,"errorMessage":"failed to mount blob %s to %s: %w","messagePattern":"failed to mount blob (.+?) to (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/registryclient/client.go","lineNumber":85,"sourceCode":"// MountBlob into the registry, so it can be referenced by a manifest\nfunc (c *client) MountBlob(ctx context.Context, sourceRef reference.Canonical, targetRef reference.Named) error {\n\trepoEndpoint, err := newDefaultRepositoryEndpoint(targetRef, c.insecureRegistry)\n\tif err != nil {\n\t\treturn err\n\t}\n\trepoEndpoint.actions = []string{\"pull\", \"push\"}\n\trepo, err := c.getRepositoryForReference(ctx, targetRef, repoEndpoint)\n\tif err != nil {\n\t\treturn err\n\t}\n\tlu, err := repo.Blobs(ctx).Create(ctx, distributionclient.WithMountFrom(sourceRef))\n\tswitch err.(type) {\n\tcase distribution.ErrBlobMounted:\n\t\tlogrus.Debugf(\"mount of blob %s succeeded\", sourceRef)\n\t\treturn nil\n\tcase nil:\n\tdefault:\n\t\treturn fmt.Errorf(\"failed to mount blob %s to %s: %w\", sourceRef, targetRef, err)\n\t}\n\t_ = lu.Cancel(ctx)\n\tlogrus.Debugf(\"mount of blob %s created\", sourceRef)\n\treturn ErrBlobCreated{From: sourceRef, Target: targetRef}\n}\n\n// PutManifest sends the manifest to a registry and returns the new digest\nfunc (c *client) PutManifest(ctx context.Context, ref reference.Named, manifest distribution.Manifest) (digest.Digest, error) {\n\trepoEndpoint, err := newDefaultRepositoryEndpoint(ref, c.insecureRegistry)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\trepoEndpoint.actions = []string{\"pull\", \"push\"}\n\trepo, err := c.getRepositoryForReference(ctx, ref, repoEndpoint)\n\tif err != nil {\n\t\treturn \"\", err\n\t}","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/internal/registryclient/client.go#L67-L103","documentation":"Returned by client.MountBlob when repository.Blobs(ctx).Create with WithMountFrom(sourceRef) returns an error that is neither distribution.ErrBlobMounted nor nil. A cross-repository blob mount is attempted when pushing; only the ErrBlobMounted success type is expected, anything else (blob unknown, permission, network) is wrapped here.","triggerScenarios":"Pushing an image and attempting to mount a layer from a source repo to a target repo when the registry denies the mount or the source blob is missing — typically missing cross-repo mount permission, source digest not present, or transport error.","commonSituations":"Target registry lacks cross-repository mount support/permission; source blob was deleted/garbage-collected; pushing to a registry that requires the blob to exist first; network blip during mount.","solutions":["Push the source image (or upload the blob) to the target registry first so it exists.","Verify push permissions on both source and target repositories.","Retry on transient transport errors.","Use a registry that supports cross-repo blob mount (distribution >= v2)."],"exampleFix":"// before: blob not present in target, mount fails\nclient.MountBlob(ctx, srcRef, tgtRef)\n// after: push the source image so the layer exists, then mount\nclient.Push(ctx, srcImage)  // makes blob available\nclient.MountBlob(ctx, srcRef, tgtRef)","handlingStrategy":"try-catch","validationCode":"// confirm the source blob exists in target repo before mounting\nif _, err := repo.Blobs(ctx).Stat(ctx, sourceDigest); err != nil { /* upload first */ }","typeGuard":null,"tryCatchPattern":"var bne distribution.ErrBlobUnknown\nif errors.As(err, &bne) { uploadBlobFirst(); retry }","preventionTips":["Push layers before attempting cross-repo mounts.","Verify push permissions on both repos.","Retry only on transport-class errors."],"tags":["registry","blob","mount","push","distribution","docker"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}