{"record":{"id":"345970a6e63af9d1","repo":"spring-projects/spring-boot","slug":"invalid-docker-type-registry-configuration-eith","errorCode":null,"errorMessage":"Invalid Docker {type} registry configuration, either token or username/password must be provided","messagePattern":"Invalid Docker (.+?) registry configuration, either token or username/password must be provided","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/Docker.java","lineNumber":211,"sourceCode":"\n\tprivate DockerRegistryAuthentication getRegistryAuthentication(String type, @Nullable DockerRegistry registry,\n\t\t\tDockerRegistryAuthentication fallback) {\n\t\tif (registry == null || registry.isEmpty()) {\n\t\t\treturn fallback;\n\t\t}\n\t\tif (registry.hasTokenAuth() && !registry.hasUserAuth()) {\n\t\t\tString token = registry.getToken();\n\t\t\tAssert.state(token != null, \"'token' must not be null\");\n\t\t\treturn DockerRegistryAuthentication.token(token);\n\t\t}\n\t\tif (registry.hasUserAuth() && !registry.hasTokenAuth()) {\n\t\t\tString username = registry.getUsername();\n\t\t\tString password = registry.getPassword();\n\t\t\tAssert.state(username != null, \"'username' must not be null\");\n\t\t\tAssert.state(password != null, \"'password' must not be null\");\n\t\t\treturn DockerRegistryAuthentication.user(username, password, registry.getUrl(), registry.getEmail());\n\t\t}\n\t\tthrow new IllegalArgumentException(\"Invalid Docker \" + type\n\t\t\t\t+ \" registry configuration, either token or username/password must be provided\");\n\t}\n\n\t/**\n\t * Encapsulates Docker registry authentication configuration options.\n\t */\n\tpublic static class DockerRegistry {\n\n\t\tprivate @Nullable String username;\n\n\t\tprivate @Nullable String password;\n\n\t\tprivate @Nullable String url;\n\n\t\tprivate @Nullable String email;\n\n\t\tprivate @Nullable String token;\n","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/270dfe353fb830fd69b823a8a859287ff103854b/build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/Docker.java#L193-L229","documentation":"IllegalArgumentException thrown by Docker's registry-authentication builder when a DockerRegistry entry provides neither token auth nor username/password auth. The branch logic accepts token-only, user-only, or — implicitly via fallthrough — none; reaching the final throw means the configuration is incomplete for the given registry type (builder or publish).","triggerScenarios":"Declaring <docker><builder> or <docker><publish> registry entries (or tags/publish-registries) where the entry has neither <token> nor a <username>+<password> pair. The `type` placeholder distinguishes builder auth from publish auth.","commonSituations":"Listing a registry URL or email without credentials; providing username but no password (or vice versa); using a registry entry meant only as a tag alias while trying to publish; misconfigured environment variables for CI registry auth.","solutions":["Provide either <token>...</token> OR <username>+<password> for each registry entry, not neither.","If using env-driven config (DOCKER_AUTH_* / SPRING_BOOT_DOCKER_*), confirm the variables are exported in the build environment.","Remove registry entries that are tag aliases (no auth needed) from the auth-requiring builder/publish list.","Use a Docker credential helper / ~/.docker/config.json and drop the explicit block entirely."],"exampleFix":"// before: <publishRegistries><registry><username>ciuser</username></registry></publishRegistries>\n// after:  <publishRegistries><registry><username>ciuser</username><password>${env.REGISTRY_PASS}</password></registry></publishRegistries>","handlingStrategy":"validation","validationCode":"// Validate each registry entry before invoking build-image/push:\nfor (Docker.DockerRegistry r : registries) {\n    boolean hasToken = r.getToken() != null;\n    boolean hasUser  = r.getUsername() != null && r.getPassword() != null;\n    if (!hasToken && !hasUser) {\n        throw new IllegalArgumentException(\n            \"Registry \" + r.getUrl() + \" has neither token nor username/password\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    // invoke build-image or push-image\n} catch (IllegalArgumentException ex) {\n    if (ex.getMessage().contains(\"registry configuration, either token or username/password\")) {\n        // add <token> or <username>+<password> to the offending registry\n    }\n    throw ex;\n}","preventionTips":["Prefer a Docker credential helper (~/.docker/config.json) over inline credentials.","Inject registry passwords from CI secrets, never hard-code.","Validate registry entries in a pre-build check."],"tags":["spring-boot","maven-plugin","docker","registry","authentication"],"backgroundTag":null,"analyzedSha":"270dfe353fb830fd69b823a8a859287ff103854b","analyzedAt":"2026-08-11T19:42:06.541Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}