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
- Add either "archive": <path> or "files": [...] to the layer entry.
- Check spelling of the property keys ('archive', 'files').
- 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
- Every layer entry must contain exactly one content source: archive or files
- Check for key typos (files, not file)
- Lint build files in CI
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
- Could not parse layer entry, missing required property 'name
- Cannot apply includes/excludes on single file copy directive
- octalPermissions must be a 3-digit octal number (000-777)
- The class file (${jarEntry}) is of an invalid format.
- Reached end of class file (${jarEntry}) before being able to
AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06).
Data as JSON: /api/errors/a37052a41d3c3ec4.
Report an issue: GitHub.