{"record":{"id":"4708123fde304f06","repo":"GoogleContainerTools/jib","slug":"helpfulsuggestions-fornocredentialsdefined-regis","errorCode":null,"errorMessage":"${helpfulSuggestions.forNoCredentialsDefined(registryUnauthorizedException.getImageReference())}","messagePattern":"\\$\\{helpfulSuggestions\\.forNoCredentialsDefined\\(registryUnauthorizedException\\.getImageReference\\(\\)\\)\\}","errorType":"exception","errorClass":"BuildStepsExecutionException","httpStatus":null,"severity":"error","filePath":"jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/JibBuildRunner.java","lineNumber":182,"sourceCode":"        helpfulSuggestions,\n        String.format(STARTUP_MESSAGE_FORMAT_FOR_TARBALL, outputPath.toString()),\n        String.format(SUCCESS_MESSAGE_FORMAT_FOR_TARBALL, outputPath.toString()));\n  }\n\n  private static void handleRegistryUnauthorizedException(\n      RegistryUnauthorizedException registryUnauthorizedException,\n      HelpfulSuggestions helpfulSuggestions)\n      throws BuildStepsExecutionException {\n    if (registryUnauthorizedException.getHttpResponseException().getStatusCode()\n        == HttpStatusCodes.STATUS_CODE_FORBIDDEN) {\n      // No permissions for registry/repository.\n      throw new BuildStepsExecutionException(\n          helpfulSuggestions.forHttpStatusCodeForbidden(\n              registryUnauthorizedException.getImageReference()),\n          registryUnauthorizedException);\n\n    } else {\n      throw new BuildStepsExecutionException(\n          helpfulSuggestions.forNoCredentialsDefined(\n              registryUnauthorizedException.getImageReference()),\n          registryUnauthorizedException);\n    }\n  }\n\n  private final String startupMessage;\n  private final String successMessage;\n  private final JibContainerBuilder jibContainerBuilder;\n  private final Containerizer containerizer;\n  private final Consumer<LogEvent> logger;\n  private final HelpfulSuggestions helpfulSuggestions;\n  @Nullable private Path imageDigestOutputPath;\n  @Nullable private Path imageIdOutputPath;\n  @Nullable private Path imageJsonOutputPath;\n\n  @VisibleForTesting\n  JibBuildRunner(","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/JibBuildRunner.java#L164-L200","documentation":"For a registry 401 (or any non-403 unauthorized response), handleRegistryUnauthorizedException throws a BuildStepsExecutionException with HelpfulSuggestions.forNoCredentialsDefined(imageReference). Jib could not find usable credentials for the registry and the registry rejected the (un)authenticated request.","triggerScenarios":"Pushing/pulling to a private registry without any configured credentials — no `to.auth`/`from.auth` config, no docker config.json from `docker login`, and no credential helper found for the registry.","commonSituations":"First-time pushes to a private registry; CI environments where docker config.json is absent; using a registry different from Docker Hub where no helper is auto-detected.","solutions":["Run `docker login <registry>` so Jib can pick up credentials from the Docker config.","Or set explicit auth in the build config (jib.to.auth.username/password, or from.auth for pulls).","Or configure a credential helper: `jib.to.credHelper = \"ecr-login\"` / `gcr` etc.","In CI, pass credentials via environment/system properties (jib.to.auth.username, jib.to.auth.password)."],"exampleFix":"// before\njib.to.image = \"registry.example.com/app\"  // no credentials\n// after\njib {\n  to {\n    image = \"registry.example.com/app\"\n    auth { username = \"user\"; password = System.getenv(\"REGISTRY_PASSWORD\") }\n  }\n}","handlingStrategy":"validation","validationCode":"// verify credentials resolve before building\n// docker config present?\nls ~/.docker/config.json || echo 'run docker login first'","typeGuard":null,"tryCatchPattern":"try { jibBuild() } catch (BuildStepsExecutionException e) {\n  if (e.getCause() instanceof RegistryUnauthorizedException) {\n    // 401: no credentials found — configure auth then retry\n  }\n}","preventionTips":["Run `docker login <registry>` before first builds","Configure jib.to.auth/from.auth or a credHelper explicitly in CI","Pass credentials via env/system properties, never hardcode","Ensure CI images include a populated Docker config or helper"],"tags":["docker","registry","authentication","credentials"],"backgroundTag":"missing-credentials","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"}