{"record":{"id":"853454457d2fd713","repo":"GoogleContainerTools/jib","slug":"could-not-parse-layer-entry-missing-required-prop","errorCode":null,"errorMessage":"Could not parse layer entry, missing required property 'name'","messagePattern":"Could not parse layer entry, missing required property 'name'","errorType":"validation","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/LayerSpec.java","lineNumber":48,"sourceCode":"@JsonDeserialize(using = LayerSpec.Deserializer.class)\npublic interface LayerSpec {\n  class Deserializer extends StdDeserializer<LayerSpec> {\n\n    public Deserializer() {\n      super(LayerSpec.class);\n    }\n\n    /**\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":30,"sourceCodeEnd":60,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/LayerSpec.java#L30-L60","documentation":"LayerSpec's Jackson deserializer reads the JSON node of a layer entry in a build file and dispatches to ArchiveLayerSpec or FileLayerSpec. Every layer entry must carry a 'name' property; if it does not, the deserializer throws an IOException with this message.","triggerScenarios":"Parsing a buildfile (JSON/YAML) whose layers list contains an entry lacking the required 'name' property, e.g. {\"archive\": \"app.tar\"} with no name.","commonSituations":"Hand-editing build files and dropping the name key, generating build files programmatically and omitting required fields, older build-file formats missing name.","solutions":["Add a 'name' property to every layer entry in the build file.","Validate the build file against the documented layer schema before running.","If generated, fix the generator to always emit 'name'."],"exampleFix":"// before\n{\"archive\": \"app.tar\"}\n// after\n{\"name\": \"app\", \"archive\": \"app.tar\"}","handlingStrategy":"validation","validationCode":"for (JsonNode layer : buildFile.get(\"layers\")) {\n  if (!layer.has(\"name\")) throw new IllegalArgumentException(\"Layer entry missing 'name': \" + layer);\n}","typeGuard":null,"tryCatchPattern":"try {\n  parseBuildFile(json);\n} catch (IOException e) {\n  if (e.getMessage().contains(\"missing required property 'name'\")) {\n    log.error(\"Build file layer entry needs a 'name' field\");\n  } else throw e;\n}","preventionTips":["Validate build files against the layer JSON schema","Keep 'name' as the first key in every layer entry by convention","Test generated build files in CI before use"],"tags":["json","buildfile","validation"],"backgroundTag":"missing-required-config-field","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"}