{"record":{"id":"f6601c8ca7667777","repo":"GoogleContainerTools/jib","slug":"all-layers-in-the-manifest-template-must-have-dige","errorCode":null,"errorMessage":"All layers in the manifest template must have digest set","messagePattern":"All layers in the manifest template must have digest set","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"jib-core/src/main/java/com/google/cloud/tools/jib/image/json/JsonToImageTranslator.java","lineNumber":115,"sourceCode":"   * @param containerConfigurationTemplate the template containing the diff IDs and container\n   *     configuration properties.\n   * @return the translated {@link Image}.\n   * @throws LayerCountMismatchException if the manifest and configuration contain conflicting layer\n   *     information.\n   * @throws LayerPropertyNotFoundException if adding image layers fails.\n   * @throws BadContainerConfigurationFormatException if the container configuration is in a bad\n   *     format\n   */\n  public static Image toImage(\n      BuildableManifestTemplate manifestTemplate,\n      ContainerConfigurationTemplate containerConfigurationTemplate)\n      throws LayerCountMismatchException, LayerPropertyNotFoundException,\n          BadContainerConfigurationFormatException {\n    List<ReferenceNoDiffIdLayer> layers = new ArrayList<>();\n    for (BuildableManifestTemplate.ContentDescriptorTemplate layerObjectTemplate :\n        manifestTemplate.getLayers()) {\n      if (layerObjectTemplate.getDigest() == null) {\n        throw new IllegalArgumentException(\n            \"All layers in the manifest template must have digest set\");\n      }\n\n      layers.add(\n          new ReferenceNoDiffIdLayer(\n              new BlobDescriptor(layerObjectTemplate.getSize(), layerObjectTemplate.getDigest())));\n    }\n\n    List<DescriptorDigest> diffIds = containerConfigurationTemplate.getDiffIds();\n    if (layers.size() != diffIds.size()) {\n      throw new LayerCountMismatchException(\n          \"Mismatch between image manifest and container configuration\");\n    }\n\n    Image.Builder imageBuilder = Image.builder(manifestTemplate.getClass());\n\n    for (int layerIndex = 0; layerIndex < layers.size(); layerIndex++) {\n      ReferenceNoDiffIdLayer noDiffIdLayer = layers.get(layerIndex);","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-core/src/main/java/com/google/cloud/tools/jib/image/json/JsonToImageTranslator.java#L97-L133","documentation":"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.","triggerScenarios":"Calling JsonToImageTranslator.toImage(manifestTemplate, containerConfigurationTemplate) with a manifest whose layer objects were deserialized from JSON missing the 'digest' field, or constructed programmatically without setDigest.","commonSituations":"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.","solutions":["Validate that every manifest layer has a non-null digest before calling toImage","Fix the source manifest JSON so each layer object includes a valid digest","When building templates programmatically, call setDigest(...) with a DescriptorDigest for every layer"],"exampleFix":"// before\nContentDescriptorTemplate layer = new ContentDescriptorTemplate();\nlayer.setSize(100); // digest missing\n// after\nlayer.setSize(100);\nlayer.setDigest(DescriptorDigest.fromDigest(\"sha256:abc...\"));","handlingStrategy":"validation","validationCode":"for (BuildableManifestTemplate.ContentDescriptorTemplate l : manifestTemplate.getLayers()) {\n  if (l.getDigest() == null) throw new IllegalArgumentException(\"layer missing digest\");\n}","typeGuard":null,"tryCatchPattern":"try { JsonToImageTranslator.toImage(manifest, config); } catch (IllegalArgumentException e) { /* validate manifest layers and retry with fixed manifest */ }","preventionTips":["Validate manifest JSON has a digest for every layer before translation","When building templates in code, always setDigest(...)","Validate descriptors with DescriptorDigest.fromDigest to catch malformed digests early"],"tags":["jib","manifest","digest","validation"],"backgroundTag":"empty-required-field","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}