{"record":{"id":"a37052a41d3c3ec4","repo":"GoogleContainerTools/jib","slug":"could-not-parse-entry-into-archivelayer-or-filelay","errorCode":null,"errorMessage":"Could not parse entry into ArchiveLayer or FileLayer","messagePattern":"Could not parse entry into ArchiveLayer or FileLayer","errorType":"validation","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/LayerSpec.java","lineNumber":56,"sourceCode":"    /**\n     * Deserializes to {@link ArchiveLayerSpec} if yaml contains \"archive\" field, to {@link\n     * FileLayerSpec} if yaml contains \"files\" field or throws {@link IOException} if neither is\n     * found or no \"name\" was specified for the layer entry.\n     */\n    @Override\n    public LayerSpec deserialize(JsonParser jsonParser, DeserializationContext context)\n        throws IOException {\n      JsonNode node = jsonParser.getCodec().readTree(jsonParser);\n      if (!node.has(\"name\")) {\n        throw new IOException(\"Could not parse layer entry, missing required property 'name'\");\n      }\n      if (node.has(\"archive\")) {\n        return jsonParser.getCodec().treeToValue(node, ArchiveLayerSpec.class);\n      }\n      if (node.has(\"files\")) {\n        return jsonParser.getCodec().treeToValue(node, FileLayerSpec.class);\n      }\n      throw new IOException(\"Could not parse entry into ArchiveLayer or FileLayer\");\n    }\n  }\n}\n","sourceCodeStart":38,"sourceCodeEnd":60,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/LayerSpec.java#L38-L60","documentation":"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.","triggerScenarios":"A buildfile layer entry that has a name but neither 'archive' nor 'files', e.g. {\"name\": \"libs\"} with no content source.","commonSituations":"Incomplete hand-written build files, placeholders left in generated configs, typos like 'file' instead of 'files'.","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."],"exampleFix":"// before\n{\"name\": \"libs\"}\n// after\n{\"name\": \"libs\", \"files\": [{\"src\": \"libs\", \"dest\": \"/app/libs\"}]}","handlingStrategy":"validation","validationCode":"for (JsonNode layer : buildFile.get(\"layers\")) {\n  if (layer.has(\"name\") && !layer.has(\"archive\") && !layer.has(\"files\")) {\n    throw new IllegalArgumentException(\"Layer '\" + layer.get(\"name\").asText() + \"' needs 'archive' or 'files'\");\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  parseBuildFile(json);\n} catch (IOException e) {\n  if (e.getMessage().contains(\"Could not parse entry into ArchiveLayer or FileLayer\")) {\n    log.error(\"Each layer must define either 'archive' or 'files'\");\n  } else throw e;\n}","preventionTips":["Every layer entry must contain exactly one content source: archive or files","Check for key typos (files, not file)","Lint build files in CI"],"tags":["json","buildfile","validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}