GoogleContainerTools/jib · error · IllegalArgumentException

All layers in the manifest template must have digest set

Error message

All layers in the manifest template must have digest set

What it means

JsonToImageTranslator.toImage requires every layer entry in the manifest template to carry a digest. When a ContentDescriptorTemplate layer has a null digest, it cannot form a valid BlobDescriptor, so an IllegalArgumentException is thrown.

Source

Thrown at jib-core/src/main/java/com/google/cloud/tools/jib/image/json/JsonToImageTranslator.java:115

   * @param containerConfigurationTemplate the template containing the diff IDs and container
   *     configuration properties.
   * @return the translated {@link Image}.
   * @throws LayerCountMismatchException if the manifest and configuration contain conflicting layer
   *     information.
   * @throws LayerPropertyNotFoundException if adding image layers fails.
   * @throws BadContainerConfigurationFormatException if the container configuration is in a bad
   *     format
   */
  public static Image toImage(
      BuildableManifestTemplate manifestTemplate,
      ContainerConfigurationTemplate containerConfigurationTemplate)
      throws LayerCountMismatchException, LayerPropertyNotFoundException,
          BadContainerConfigurationFormatException {
    List<ReferenceNoDiffIdLayer> layers = new ArrayList<>();
    for (BuildableManifestTemplate.ContentDescriptorTemplate layerObjectTemplate :
        manifestTemplate.getLayers()) {
      if (layerObjectTemplate.getDigest() == null) {
        throw new IllegalArgumentException(
            "All layers in the manifest template must have digest set");
      }

      layers.add(
          new ReferenceNoDiffIdLayer(
              new BlobDescriptor(layerObjectTemplate.getSize(), layerObjectTemplate.getDigest())));
    }

    List<DescriptorDigest> diffIds = containerConfigurationTemplate.getDiffIds();
    if (layers.size() != diffIds.size()) {
      throw new LayerCountMismatchException(
          "Mismatch between image manifest and container configuration");
    }

    Image.Builder imageBuilder = Image.builder(manifestTemplate.getClass());

    for (int layerIndex = 0; layerIndex < layers.size(); layerIndex++) {
      ReferenceNoDiffIdLayer noDiffIdLayer = layers.get(layerIndex);

View on GitHub (pinned to fb949e2676)

Solutions

  1. Validate that every manifest layer has a non-null digest before calling toImage
  2. Fix the source manifest JSON so each layer object includes a valid digest
  3. When building templates programmatically, call setDigest(...) with a DescriptorDigest for every layer

Example fix

// before
ContentDescriptorTemplate layer = new ContentDescriptorTemplate();
layer.setSize(100); // digest missing
// after
layer.setSize(100);
layer.setDigest(DescriptorDigest.fromDigest("sha256:abc..."));
Defensive patterns

Strategy: validation

Validate before calling

for (BuildableManifestTemplate.ContentDescriptorTemplate l : manifestTemplate.getLayers()) {
  if (l.getDigest() == null) throw new IllegalArgumentException("layer missing digest");
}

Try / catch

try { JsonToImageTranslator.toImage(manifest, config); } catch (IllegalArgumentException e) { /* validate manifest layers and retry with fixed manifest */ }

Prevention

When it happens

Trigger: Calling JsonToImageTranslator.toImage(manifestTemplate, containerConfigurationTemplate) with a manifest whose layer objects were deserialized from JSON missing the 'digest' field, or constructed programmatically without setDigest.

Common situations: Manually built/partially populated manifest templates; malformed or hand-edited manifest JSON; a registry manifest variant that Jib parsed with missing layer digests; test fixtures with incomplete descriptors.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06). Data as JSON: /api/errors/f6601c8ca7667777. Report an issue: GitHub.