cypress-io / docker-image-not-found

If you want to do something only if the Docker Hub does not have an image
0 stars 2 forks source link

InvalidContentError for Docker image using OCI imageType #6

Open MikeMcC399 opened 3 weeks ago

MikeMcC399 commented 3 weeks ago

Issue

When docker-image-not-found attempts to test an image that has been published with imageType using oci, it fails with an error message:

RestError [InvalidContentError]: unsupported schema version 2 in <repo:tag> manifest

Steps to reproduce

npm install docker-image-not-found -g
docker-image-not-found --repo ubuntu
docker manifest inspect ubuntu

Logs

$ docker-image-exists --repo ubuntu
RestError [InvalidContentError]: unsupported schema version 2 in ubuntu:latest manifest
    at _afterCall (/home/mike/n/lib/node_modules/docker-image-exists/node_modules/docker-registry-client/lib/registry-client-v2.js:1469:24)
    at IncomingMessage.finish (/home/mike/n/lib/node_modules/docker-image-exists/node_modules/docker-registry-client/lib/docker-json-client.js:171:13)
    at Object.onceWrapper (node:events:633:28)
    at IncomingMessage.emit (node:events:531:35)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  jse_shortmsg: 'unsupported schema version 2 in ubuntu:latest manifest',
  jse_info: {},
  body: {
    code: 'InvalidContent',
    message: 'unsupported schema version 2 in ubuntu:latest manifest'
  },
  restCode: 'InvalidContent',
  cause: [Function: we_cause]
}
$ docker manifest inspect ubuntu
{
   "schemaVersion": 2,
   "mediaType": "application/vnd.oci.image.index.v1+json",
   "manifests": [
      {
         "mediaType": "application/vnd.oci.image.manifest.v1+json",
         "size": 424,
         "digest": "sha256:c920ba4cfca05503764b785c16b76d43c83a6df8d1ab107e7e6610000d94315c",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.oci.image.manifest.v1+json",
         "size": 424,
         "digest": "sha256:8550f6af59aad999f559457c57eaea97078b9b17ac98f794e2f5dde953857798",
         "platform": {
            "architecture": "arm",
            "os": "linux",
            "variant": "v7"
         }
      },
      {
         "mediaType": "application/vnd.oci.image.manifest.v1+json",
         "size": 424,
         "digest": "sha256:010f94447a26deb0dcdbbeb08d7dfcd87b64c40b4f25d0cf4d582949b735039d",
         "platform": {
            "architecture": "arm64",
            "os": "linux",
            "variant": "v8"
         }
      },
      {
         "mediaType": "application/vnd.oci.image.manifest.v1+json",
         "size": 424,
         "digest": "sha256:a3b5c0d95b7ce708cd05f3d254e093f1b53ea1c699f1d5a0c76743e683c9eaa2",
         "platform": {
            "architecture": "ppc64le",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.oci.image.manifest.v1+json",
         "size": 424,
         "digest": "sha256:3963c438d67a34318a3672faa6debd1dfff48e5d52de54305988b932c61514ca",
         "platform": {
            "architecture": "s390x",
            "os": "linux"
         }
      }
   ]
}

Versions

Component Version
docker-image-not-found 1.1.1
Ubuntu 22.04.4 LTS
Node.js 20.15.0 LTS
MikeMcC399 commented 3 weeks ago

Although the logs are reporting a RestError for a Docker image like ubuntu:jammy-20240627.1 with an oci imageType in its Docker image manifest, in fact the return code 1 is correct for such an oci image which is found.

Docker tag mediaType return code meaning
ubuntu:jammy-20240627.1 oci 1 image exists or other error
ubuntu:jammy-20221130 docker 1 image exists or other error
cypress/factory:4.0.2 docker 1 image exists or other error
cypress/factory:missing - 0 image does not exist
MikeMcC399 commented 3 weeks ago