{"record":{"id":"a787754c6999aaf5","repo":"GoogleContainerTools/jib","slug":"image-name-must-be-set-when-building-a-tarimage-u","errorCode":null,"errorMessage":"Image name must be set when building a TarImage; use TarImage#named(...) to set the name of the target image","messagePattern":"Image name must be set when building a TarImage; use TarImage#named\\(\\.\\.\\.\\) to set the name of the target image","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"jib-core/src/main/java/com/google/cloud/tools/jib/api/Containerizer.java","lineNumber":113,"sourceCode":"        DockerClientResolver.resolve(dockerDaemonImage.getDockerEnvironment())\n            .orElse(\n                new CliDockerClient(\n                    dockerDaemonImage.getDockerExecutable(),\n                    dockerDaemonImage.getDockerEnvironment()));\n\n    return to(dockerClient, dockerDaemonImage);\n  }\n\n  /**\n   * Gets a new {@link Containerizer} that containerizes to a tarball archive.\n   *\n   * @param tarImage the {@link TarImage} that defines target output file\n   * @return a new {@link Containerizer}\n   */\n  public static Containerizer to(TarImage tarImage) {\n    Optional<ImageReference> imageReference = tarImage.getImageReference();\n    if (!imageReference.isPresent()) {\n      throw new IllegalArgumentException(\n          \"Image name must be set when building a TarImage; use TarImage#named(...) to set the name\"\n              + \" of the target image\");\n    }\n\n    ImageConfiguration imageConfiguration =\n        ImageConfiguration.builder(imageReference.get()).build();\n\n    Function<BuildContext, StepsRunner> stepsRunnerFactory =\n        buildContext -> StepsRunner.begin(buildContext).tarBuildSteps(tarImage.getPath());\n\n    return new Containerizer(\n        DESCRIPTION_FOR_TARBALL, imageConfiguration, stepsRunnerFactory, false);\n  }\n\n  /**\n   * Gets a new {@link Containerizer} that containerizes to a Docker daemon.\n   *\n   * @param dockerClient the {@link DockerClient} to connect","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-core/src/main/java/com/google/cloud/tools/jib/api/Containerizer.java#L95-L131","documentation":"Containerizer.to(TarImage) builds an OCI/Docker tarball that must be tagged with an image name. If TarImage#named(...) was never called, the optional ImageReference is empty and this IllegalArgumentException is thrown because a tar image cannot be built namelessly.","triggerScenarios":"Calling Containerizer.to(TarImage.at(path)) without chaining TarImage#named(\"ref\"), then building.","commonSituations":"Migrating code from registry builds to tar outputs; copying examples that omit .named(); constructing TarImage programmatically and forgetting the name step.","solutions":["Call TarImage#named(...) with a valid image reference before passing to Containerizer.to","Ensure the ImageReference is set (e.g. TarImage.at(Paths.get(\"out.tar\")).named(\"my/repo:tag\"))","Validate the reference format if named() was called but with an invalid string that didn't populate the reference"],"exampleFix":"// before\nTarImage tarImage = TarImage.at(Paths.get(\"image.tar\"));\nContainerizer.to(tarImage);\n// after\nContainerizer.to(TarImage.at(Paths.get(\"image.tar\")).named(\"my-app:latest\"));","handlingStrategy":"type-guard","validationCode":"if (!tarImage.getImageReference().isPresent()) { throw new IllegalStateException(\"Call TarImage#named before building\"); }","typeGuard":"boolean isNamedTarImage(TarImage t) { return t.getImageReference().isPresent(); }","tryCatchPattern":"try { containerizer.build(); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"TarImage#named\")) { /* rebuild containerizer with named image */ } }","preventionTips":["Always chain .named(...) on TarImage.at(...)","Centralize TarImage construction in a helper that enforces naming","Unit-test containerizer configuration before builds"],"tags":["jib","tar-image","image-reference","containerizer"],"backgroundTag":"missing-required-argument","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"}