{"record":{"id":"2472f2d6d34001f2","repo":"spring-projects/spring-boot","slug":"error-parsing-docker-context-metadata-file","errorCode":null,"errorMessage":"Error parsing Docker context metadata file '{}'","messagePattern":"Error parsing Docker context metadata file '(.+?)'","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/configuration/DockerConfigurationMetadata.java","lineNumber":146,"sourceCode":"\tprivate static DockerContext createDockerContext(String configLocation, @Nullable String currentContext) {\n\t\tif (currentContext == null || DEFAULT_CONTEXT.equals(currentContext)) {\n\t\t\treturn DockerContext.empty();\n\t\t}\n\t\tString hash = asHash(currentContext);\n\t\tPath metaPath = Path.of(configLocation, CONTEXTS_DIR, META_DIR, hash, CONTEXT_FILE_NAME);\n\t\tPath tlsPath = Path.of(configLocation, CONTEXTS_DIR, TLS_DIR, hash, DOCKER_ENDPOINT);\n\t\tif (!metaPath.toFile().exists()) {\n\t\t\tthrow new IllegalArgumentException(\"Docker context '\" + currentContext + \"' does not exist\");\n\t\t}\n\t\ttry {\n\t\t\tDockerContext context = DockerContext.fromJson(readPathContent(metaPath));\n\t\t\tif (tlsPath.toFile().isDirectory()) {\n\t\t\t\treturn context.withTlsPath(tlsPath.toString());\n\t\t\t}\n\t\t\treturn context;\n\t\t}\n\t\tcatch (JacksonException ex) {\n\t\t\tthrow new IllegalStateException(\"Error parsing Docker context metadata file '\" + metaPath + \"'\", ex);\n\t\t}\n\t}\n\n\tprivate static String asHash(String currentContext) {\n\t\ttry {\n\t\t\tMessageDigest digest = MessageDigest.getInstance(\"SHA-256\");\n\t\t\tbyte[] hash = digest.digest(currentContext.getBytes(StandardCharsets.UTF_8));\n\t\t\treturn HexFormat.of().formatHex(hash);\n\t\t}\n\t\tcatch (NoSuchAlgorithmException ex) {\n\t\t\tthrow new IllegalStateException(\"SHA-256 is not available\", ex);\n\t\t}\n\t}\n\n\tprivate static String readPathContent(Path path) {\n\t\ttry {\n\t\t\treturn Files.readString(path);\n\t\t}","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/270dfe353fb830fd69b823a8a859287ff103854b/buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/configuration/DockerConfigurationMetadata.java#L128-L164","documentation":"The named Docker context's meta.json exists (the existence check at line 135 passed) but DockerContext.fromJson(readPathContent(metaPath)) threw a JacksonException. Docker's context metadata file is normally written by `docker context create` and contains Endpoints/docker/Host and Endpoints/docker/SkipTLSVerify fields; anything that corrupts it triggers this wrap into IllegalStateException naming metaPath.","triggerScenarios":"createDockerContext reaches line 139 (DockerContext.fromJson), the file's bytes are readable but not valid JSON or do not match the expected node structure, and JacksonException is caught at line 145.","commonSituations":"Hand-editing contexts/meta/<hash>/meta.json; a crashed `docker context create` leaving a truncated file; schema drift from an incompatible Docker CLI version; copying only part of the contexts/ tree.","solutions":["Validate the file: `jq < ~/.docker/contexts/meta/<hash>/meta.json`.","Recreate the context: `docker context rm <name> && docker context create <name> --docker <endpoint>`.","Fall back to the default context: `docker context use default`."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate the context's meta.json before invoking the build\nPath meta = resolveContextMetaPath(configLocation, currentContext);\nif (Files.exists(meta)) {\n    try {\n        SharedJsonMapper.get().readTree(Files.readString(meta));\n    } catch (Exception e) {\n        throw new IllegalStateException(\n            \"Docker context meta.json at \" + meta + \" is invalid: \" + e.getMessage(), e);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    metadata.getContext();\n} catch (IllegalStateException ex) {\n    if (ex.getCause() instanceof JacksonException\n            && ex.getMessage().startsWith(\"Error parsing Docker context metadata file\")) {\n        // hint: recreate the context with `docker context rm` + `docker context create`\n    }\n    throw ex;\n}","preventionTips":["Never hand-edit contexts/meta/<hash>/meta.json.","Recreate contexts through the docker CLI rather than copying files.","Validate meta.json with jq when copying a config tree."],"tags":["docker","configuration","json","docker-context","buildpack"],"backgroundTag":null,"analyzedSha":"270dfe353fb830fd69b823a8a859287ff103854b","analyzedAt":"2026-08-11T19:42:06.541Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}