Skip to content

Error is not well handled in oras manifest push #627

@shizhMSFT

Description

@shizhMSFT

The err from manifests.Resolve(ctx, ref) is not well handled and causes oras print out incorrect output.

got, err := manifests.Resolve(ctx, ref)
// push the manifest if the reference does not exist;
// if the reference exists, then push the manifest if digests mismatch
if errors.Is(err, errdef.ErrNotFound) || (err == nil && got.Digest != desc.Digest) {
if err = display.PrintStatus(desc, "Uploading", verbose); err != nil {
return err
}
if err = manifests.PushReference(ctx, desc, bytes.NewReader(contentBytes), ref); err != nil {
return err
}
if err = display.PrintStatus(desc, "Uploaded ", verbose); err != nil {
return err
}
} else {
if err := display.PrintStatus(desc, "Exists", verbose); err != nil {
return err
}
}

Sample output:

$ oras manifest push ${name} manifest.json --debug
DEBU[0000]  Request URL: "https://host.docker.internal:5000/v2/hello/manifests/sha256:361358b5c6b151255f3ade1d0dc0bfc64d0ec1455c55c9c86cbfc027b4981308"
DEBU[0000]  Request method: "HEAD"
DEBU[0000]  Request headers:
DEBU[0000]    "Accept": "application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json, application/vnd.cncf.oras.artifact.manifest.v1+json"
DEBU[0000]    "User-Agent": "oras/0.15.0"
ERRO[0000] Error in getting response: %!w(tls.RecordHeaderError={first record does not look like a TLS handshake [72 84 84 80 47] 0xc000286000})
Pushed host.docker.internal:5000/hello
Digest: sha256:361358b5c6b151255f3ade1d0dc0bfc64d0ec1455c55c9c86cbfc027b4981308

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions