{"record":{"id":"0cab6ad0d24941e9","repo":"spring-projects/spring-boot","slug":"error-creating-docker-registry-authentication-head","errorCode":null,"errorMessage":"Error creating Docker registry authentication header","messagePattern":"Error creating Docker registry authentication header","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/configuration/JsonEncodedDockerRegistryAuthentication.java","lineNumber":48,"sourceCode":" *\n * @author Scott Frederick\n */\nclass JsonEncodedDockerRegistryAuthentication implements DockerRegistryAuthentication {\n\n\t@JsonIgnore\n\tprivate @Nullable String authHeader;\n\n\t@Override\n\tpublic @Nullable String getAuthHeader() {\n\t\treturn this.authHeader;\n\t}\n\n\tprotected void createAuthHeader() {\n\t\ttry {\n\t\t\tthis.authHeader = Base64.getUrlEncoder().encodeToString(SharedJsonMapper.get().writeValueAsBytes(this));\n\t\t}\n\t\tcatch (JacksonException ex) {\n\t\t\tthrow new IllegalStateException(\"Error creating Docker registry authentication header\", ex);\n\t\t}\n\t}\n\n}\n","sourceCodeStart":30,"sourceCodeEnd":53,"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/JsonEncodedDockerRegistryAuthentication.java#L30-L53","documentation":"JsonEncodedDockerRegistryAuthentication.createAuthHeader serializes the auth object to JSON via SharedJsonMapper, then Base64URL-encodes the bytes to build the X-Registry-Auth header sent to the Docker daemon. A JacksonException means the object graph could not be serialized. With the shipped concrete auth types (only String/scalar fields) this branch is effectively unreachable.","triggerScenarios":"createAuthHeader() at line 45 calls SharedJsonMapper.get().writeValueAsBytes(this) and Jackson throws because a field on the object (or a subclass) holds a non-serializable value, a circular reference, or an annotation mismatch.","commonSituations":"A custom subclass of JsonEncodedDockerRegistryAuthentication adding a non-serializable field (e.g. a KeyStore, InputStream, or lambda) without @JsonIgnore; a Jackson version/mapper mismatch where annotations are not honored.","solutions":["Inspect the wrapped JacksonException cause to find the offending property name.","Annotate the non-serializable field with @JsonIgnore, or remove it from the auth object.","Keep auth POJOs limited to String/scalar fields (username, password, identitytoken, registrytoken)."],"exampleFix":"// before: subclass adds a non-serializable field\nclass MyAuth extends JsonEncodedDockerRegistryAuthentication {\n    private KeyStore trustStore; // triggers JacksonException\n}\n// after: exclude it\nclass MyAuth extends JsonEncodedDockerRegistryAuthentication {\n    @JsonIgnore\n    private KeyStore trustStore;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    auth.createAuthHeader();\n} catch (IllegalStateException ex) {\n    if (ex.getCause() instanceof JacksonException) {\n        // fall back to an anonymous (empty) X-Registry-Auth header\n        authHeader = Base64.getUrlEncoder().encodeToString(\"{}\".getBytes());\n    } else throw ex;\n}","preventionTips":["Keep auth POJOs limited to String/scalar fields (username, password, identitytoken, registrytoken).","Annotate any non-serializable field on subclasses with @JsonIgnore.","Unit-test Jackson serialization of custom auth subclasses."],"tags":["docker","authentication","json","serialization","buildpack"],"backgroundTag":null,"analyzedSha":"270dfe353fb830fd69b823a8a859287ff103854b","analyzedAt":"2026-08-11T19:42:06.541Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}