GoogleContainerTools/jib · error · RegistryErrorException

Did not receive Content-Length header

Error message

Did not receive Content-Length header

What it means

Thrown by BlobChecker.handleResponse when the registry's response to a blob existence/descriptor check (HEAD /v2/<name>/blobs/<digest>) has no Content-Length header. Jib builds the blob's descriptor (size + digest) from that header, so its absence fails the check. It surfaces as RegistryErrorException with this reason.

Source

Thrown at jib-core/src/main/java/com/google/cloud/tools/jib/registry/BlobChecker.java:54

 */
class BlobChecker implements RegistryEndpointProvider<Optional<BlobDescriptor>> {

  private final RegistryEndpointRequestProperties registryEndpointRequestProperties;
  private final DescriptorDigest blobDigest;

  BlobChecker(
      RegistryEndpointRequestProperties registryEndpointRequestProperties,
      DescriptorDigest blobDigest) {
    this.registryEndpointRequestProperties = registryEndpointRequestProperties;
    this.blobDigest = blobDigest;
  }

  /** Returns the BLOB's content descriptor. */
  @Override
  public Optional<BlobDescriptor> handleResponse(Response response) throws RegistryErrorException {
    long contentLength = response.getContentLength();
    if (contentLength < 0) {
      throw new RegistryErrorExceptionBuilder(getActionDescription())
          .addReason("Did not receive Content-Length header")
          .build();
    }

    return Optional.of(new BlobDescriptor(contentLength, blobDigest));
  }

  @Override
  public Optional<BlobDescriptor> handleHttpResponseException(ResponseException responseException)
      throws ResponseException {
    if (responseException.getStatusCode() != HttpStatusCodes.STATUS_CODE_NOT_FOUND) {
      throw responseException;
    }

    if (responseException.getContent() == null) {
      // TODO: The Google HTTP client gives null content for HEAD requests. Make the content never
      // be null, even for HEAD requests.
      return Optional.empty();

View on GitHub (pinned to fb949e2676)

Solutions

  1. Check with `curl -I` whether the blob URL returns Content-Length; if not, the registry/proxy is nonconforming.
  2. Remove or fix any proxy/CDN layer that strips the Content-Length header from HEAD responses.
  3. Verify the blob actually exists; some registries return odd responses for missing blobs.
  4. Use a compliant registry implementation or upgrade its version if it's a known header bug.
Defensive patterns

Strategy: try-catch

Validate before calling

// preflight: HEAD on a blob must return Content-Length
// curl -sI https://registry.example.com/v2/<image>/blobs/<digest> | grep -i content-length

Try / catch

// catch and diagnose header-stripping proxies
try {
    jibContainerBuilder.containerize();
} catch (RegistryErrorException e) {
    if (e.getMessage().contains("Content-Length")) {
        throw new IllegalStateException("Registry/proxy omitted Content-Length on blob HEAD — check intermediary layers", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Registry responds 200 to the blob HEAD request without a Content-Length header — e.g. chunked responses from proxies or nonconforming registry implementations.

Common situations: Registries behind proxies that strip headers, CDN/mirror layers removing Content-Length, or minimal custom registry implementations that skip the header on HEAD responses.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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