{"record":{"id":"26d7f2eb25b361e3","repo":"GoogleContainerTools/jib","slug":"platforms-set-cannot-be-empty","errorCode":null,"errorMessage":"platforms set cannot be empty","messagePattern":"platforms set cannot be empty","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"jib-build-plan/src/main/java/com/google/cloud/tools/jib/api/buildplan/ContainerBuildPlan.java","lineNumber":105,"sourceCode":"      platforms.add(new Platform(architecture, os));\n      return this;\n    }\n\n    /**\n     * Sets a desired platform (properties including OS and architecture) list. If the base image\n     * reference is a Docker manifest list or an OCI image index, an image builder may select the\n     * base images matching the given platforms. If the base image reference is an image manifest,\n     * an image builder may ignore the given platforms and use the platform of the base image or may\n     * decide to raise on error.\n     *\n     * <p>Note that a new build plan starts with \"amd64/linux\" as the default platform.\n     *\n     * @param platforms list of platforms to select base images in case of a manifest list\n     * @return this\n     */\n    public Builder setPlatforms(Set<Platform> platforms) {\n      if (platforms.isEmpty()) {\n        throw new IllegalArgumentException(\"platforms set cannot be empty\");\n      }\n      this.platforms = new LinkedHashSet<>(platforms);\n      return this;\n    }\n\n    /**\n     * Sets the container image creation time. The default is {@link Instant#EPOCH}.\n     *\n     * @param creationTime the container image creation time\n     * @return this\n     */\n    public Builder setCreationTime(Instant creationTime) {\n      this.creationTime = creationTime;\n      return this;\n    }\n\n    /**\n     * Sets the format to build the container image as. Use {@link ImageFormat#Docker} for Docker","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-build-plan/src/main/java/com/google/cloud/tools/jib/api/buildplan/ContainerBuildPlan.java#L87-L123","documentation":"ContainerBuildPlan.Builder.setPlatforms() requires a non-empty set of Platform entries for multi-platform (manifest list) builds. An empty set would leave the build plan with no target platform, so it throws IllegalArgumentException immediately.","triggerScenarios":"Calling setPlatforms(Collections.emptySet()) or setPlatforms(new HashSet<>()) or a Set filtered down to zero entries.","commonSituations":"Building a build-plan JSON programmatically; computing platforms from config where an empty/missing list yields an empty set.","solutions":["Provide at least one Platform, e.g. setPlatforms(ImmutableSet.of(Platform.builder().setArchitecture(\"amd64\").setOs(\"linux\").build()))","Default to the current host platform when no platforms are configured","Guard upstream: throw a clearer error when the configured platform list is empty"],"exampleFix":"// before\nbuilder.setPlatforms(platforms.stream().filter(p -> p.getOs().equals(\"linux\")).collect(Collectors.toSet())); // may be empty\n// after\nSet<Platform> selected = ...;\nif (selected.isEmpty()) { selected = ImmutableSet.of(Platform.builder().setArchitecture(\"amd64\").setOs(\"linux\").build()); }\nbuilder.setPlatforms(selected);","handlingStrategy":"validation","validationCode":"if (platforms == null || platforms.isEmpty()) platforms = Set.of(Platform.builder().setArchitecture(\"amd64\").setOs(\"linux\").build());","typeGuard":"boolean hasPlatforms(BuildPlan plan) { return plan.getPlatforms() != null && !plan.getPlatforms().isEmpty(); }","tryCatchPattern":"try { builder.setPlatforms(platforms); } catch (IllegalArgumentException e) { builder.setPlatforms(defaultPlatforms); }","preventionTips":["Never construct the set via an unguarded filter that can drop all entries","Default to the current host platform when user config is empty","Validate platform lists at config-parse time with a clear message"],"tags":["jib","build-plan","illegal-argument"],"backgroundTag":"empty-required-field","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}