GoogleContainerTools/jib · error · IOException

Could not parse entry into ArchiveLayer or FileLayer

Error message

Could not parse entry into ArchiveLayer or FileLayer

What it means

After confirming a layer entry has a 'name', the LayerSpec deserializer needs either an 'archive' property (making it an ArchiveLayerSpec) or a 'files' property (making it a FileLayerSpec). If neither exists it throws an IOException with this message.

Source

Thrown at jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/LayerSpec.java:56

    /**
     * Deserializes to {@link ArchiveLayerSpec} if yaml contains "archive" field, to {@link
     * FileLayerSpec} if yaml contains "files" field or throws {@link IOException} if neither is
     * found or no "name" was specified for the layer entry.
     */
    @Override
    public LayerSpec deserialize(JsonParser jsonParser, DeserializationContext context)
        throws IOException {
      JsonNode node = jsonParser.getCodec().readTree(jsonParser);
      if (!node.has("name")) {
        throw new IOException("Could not parse layer entry, missing required property 'name'");
      }
      if (node.has("archive")) {
        return jsonParser.getCodec().treeToValue(node, ArchiveLayerSpec.class);
      }
      if (node.has("files")) {
        return jsonParser.getCodec().treeToValue(node, FileLayerSpec.class);
      }
      throw new IOException("Could not parse entry into ArchiveLayer or FileLayer");
    }
  }
}

View on GitHub (pinned to fb949e2676)

Solutions

  1. Add either "archive": <path> or "files": [...] to the layer entry.
  2. Check spelling of the property keys ('archive', 'files').
  3. Validate the layer schema of your build file before building.

Example fix

// before
{"name": "libs"}
// after
{"name": "libs", "files": [{"src": "libs", "dest": "/app/libs"}]}
Defensive patterns

Strategy: validation

Validate before calling

for (JsonNode layer : buildFile.get("layers")) {
  if (layer.has("name") && !layer.has("archive") && !layer.has("files")) {
    throw new IllegalArgumentException("Layer '" + layer.get("name").asText() + "' needs 'archive' or 'files'");
  }
}

Try / catch

try {
  parseBuildFile(json);
} catch (IOException e) {
  if (e.getMessage().contains("Could not parse entry into ArchiveLayer or FileLayer")) {
    log.error("Each layer must define either 'archive' or 'files'");
  } else throw e;
}

Prevention

When it happens

Trigger: A buildfile layer entry that has a name but neither 'archive' nor 'files', e.g. {"name": "libs"} with no content source.

Common situations: Incomplete hand-written build files, placeholders left in generated configs, typos like 'file' instead of 'files'.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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