{"record":{"id":"ff31e9c30f3bf3d2","repo":"GoogleContainerTools/jib","slug":"diff-id-not-available-for-digest-only-layer","errorCode":null,"errorMessage":"Diff ID not available for digest-only layer","messagePattern":"Diff ID not available for digest-only layer","errorType":"exception","errorClass":"LayerPropertyNotFoundException","httpStatus":null,"severity":"error","filePath":"jib-core/src/main/java/com/google/cloud/tools/jib/image/DigestOnlyLayer.java","lineNumber":50,"sourceCode":"   * @param digest the digest to instantiate the {@link DigestOnlyLayer} from\n   */\n  public DigestOnlyLayer(DescriptorDigest digest) {\n    blobDescriptor = new BlobDescriptor(digest);\n  }\n\n  @Override\n  public Blob getBlob() throws LayerPropertyNotFoundException {\n    throw new LayerPropertyNotFoundException(\"Blob not available for digest-only layer\");\n  }\n\n  @Override\n  public BlobDescriptor getBlobDescriptor() {\n    return blobDescriptor;\n  }\n\n  @Override\n  public DescriptorDigest getDiffId() throws LayerPropertyNotFoundException {\n    throw new LayerPropertyNotFoundException(\"Diff ID not available for digest-only layer\");\n  }\n}\n","sourceCodeStart":32,"sourceCodeEnd":53,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-core/src/main/java/com/google/cloud/tools/jib/image/DigestOnlyLayer.java#L32-L53","documentation":"LayerPropertyNotFoundException thrown by DigestOnlyLayer.getDiffId(). A DigestOnlyLayer represents a layer reference known only by its digest (e.g. a layer pulled from a registry cache or referenced from a base image manifest) so it carries only a BlobDescriptor, never the uncompressed-layer diff ID. This is a deliberate sentinel guard: calling getDiffId() on such a reference is an API misuse because the value is structurally unavailable, not merely unloaded — the caller must obtain the diff ID from the layer's actual content or metadata instead.","triggerScenarios":"Calling Layer.getDiffId() on a DigestOnlyLayer, typically a layer built from a manifest template's descriptors where diff IDs were never provided.","commonSituations":"Reconstructing an image from a registry manifest without a container configuration (which is where diff IDs live); computing total image size/diff chains from manifest-only data; cache-key computations needing diff IDs.","solutions":["Obtain diff IDs from the container configuration (JsonToImageTranslator pairs manifest layers with config diffIds) instead of the layer itself","Use ReferenceLayer (built with a diffId) when diff IDs are required","Catch LayerPropertyNotFoundException and treat the diff ID as unavailable"],"exampleFix":"// before\nDescriptorDigest diffId = layer.getDiffId();\n// after\ntry {\n  DescriptorDigest diffId = layer.getDiffId();\n} catch (LayerPropertyNotFoundException ex) { /* digest-only layer: no diff ID */ }","handlingStrategy":"try-catch","validationCode":"// check availability: diff IDs live in the container config, not manifest layers\nboolean hasDiffId = containerConfigurationTemplate != null && containerConfigurationTemplate.getDiffIds().size() == manifestTemplate.getLayers().size();","typeGuard":null,"tryCatchPattern":"try { DescriptorDigest d = layer.getDiffId(); } catch (LayerPropertyNotFoundException e) { d = diffIdsFromConfig.get(index); }","preventionTips":["Source diff IDs from ContainerConfigurationTemplate.getDiffIds()","Pair manifest layers with config diffIds by index","Don't assume Layer API uniformly returns all properties"],"tags":["jib","docker-image","layer","diff-id"],"backgroundTag":"unsupported-operation","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"}