Skip to content

Unrecognized field "artifactType" during Jib Gradle build #4506

@tonydlo

Description

@tonydlo

Environment:

  • Jib version: 3.5.3
  • Build tool: Java 17, Gradle 9.4.1
  • OS: Windows and Linux

Description of the issue:
We are building OCI 1.1 images with newer versions of Docker (29.5.1), and Gradle Jib is no longer able to use those images as the base (FROM) image due to Unrecognized field "artifactType". This started happening after upgrading from 29.5.0, but we cannot 100% confirm that was the reason.

Note: There was another issue that talked about hitting this before, and then it mysteriously working again after 3.4.3. There was no mention of code change (nor mention of the word "artifactType" in the code base), so i suspect the user simply built the images without it afterwards.

Expected behavior:
Jib image build to succeed.

Steps to reproduce:

  1. Run the jib build command: ./gradlew jibDockerBuild

jib-gradle-plugin Configuration:

    jib {
        from {
                image = "icr.io/_REDACTED_/microservice-java:latest"
        }

        auth {
            ....
        }

        to {
            image = project.ext.dockerFullImageName
            tags = [project.ext.dockerTagName]
        }

        container {
            appRoot = "/app"
            creationTime = "USE_CURRENT_TIMESTAMP"
        }
    }

Log output:

Execution failed for task ':jibDockerBuild'.
> com.google.cloud.tools.jib.plugins.common.BuildStepsExecutionException: Unrecognized field "artifactType" (class com.google.cloud.tools.jib.image.json.OciIndexTemplate$ManifestDescriptorTemplate), not marked as ignorable (6 known properties: "size", "platform", "digest", "mediaType", "urls", "annotations"])
   at [Source: (String)"{"schemaVersion":2,"mediaType":"application/vnd.oci.image.index.v1+json","manifests":[{"mediaType":"application/vnd.docker.distribution.manifest.v2+json","size":1395,"digest":"sha256:_REDACTED_","platform":{"architecture":"amd64","os":"linux"},"artifactType":"application/vnd.docker.container.image.v1+json"},{"mediaType":"application/vnd.docker.distribution.manifest.v2+json","size":1395,"digest":"sha256:_REDACTED_"[truncated 141 chars]; line: 1, column: 315] (through reference chain: com.google.cloud.tools.jib.image.json.OciIndexTemplate["manifests"]->java.util.ArrayList[0]->com.google.cloud.tools.jib.image.json.OciIndexTemplate$ManifestDescriptorTemplate["artifactType"])

Additional Information:
Here is an example manifest. Note the new "artifactType" property:
docker manifest inspect icr.io/_REDACTED_/microservice-java:latest

{
    "schemaVersion": 2,
    "mediaType": "application/vnd.oci.image.index.v1+json",
    "manifests": [
        {
            "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
            "size": 1395,
            "digest": "sha256:_REDACTED_",
            "platform": {
                "architecture": "amd64",
                "os": "linux"
            },
            "artifactType": "application/vnd.docker.container.image.v1+json"
        },
        {
            "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
            "size": 1395,
            "digest": "sha256:_REDACTED_",
            "platform": {
                "architecture": "arm64",
                "os": "linux"
            },
            "artifactType": "application/vnd.docker.container.image.v1+json"
        }
    ]
}

Solution ideas:

  • Add it to the ignorable properties
  • Flag to ignore all unknown properties (and continue to log them)
  • Preferred: Handle the artifactType properly, throwing exceptions for artifact types Jib cannot handle (set an allowlist)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions