{"id":"9b36d9dd10f5bbb6","repo":"spring-projects/spring-boot","slug":"multiple-types-found-with-build-this-build-and","errorCode":null,"errorMessage":"Multiple types found with build '{this.build}' and format '{this.format}' use --type with a more specific value {types.keySet()}","messagePattern":"Multiple types found with build '(.+?)' and format '(.+?)' use --type with a more specific value (.+?)","errorType":"exception","errorClass":"ReportableException","httpStatus":null,"severity":"error","filePath":"cli/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java","lineNumber":389,"sourceCode":"\t\t\treturn result;\n\t\t}\n\t\telse if (isDetectType()) {\n\t\t\tMap<String, ProjectType> types = new HashMap<>(metadata.getProjectTypes());\n\t\t\tif (this.build != null) {\n\t\t\t\tfilter(types, \"build\", this.build);\n\t\t\t}\n\t\t\tif (this.format != null) {\n\t\t\t\tfilter(types, \"format\", this.format);\n\t\t\t}\n\t\t\tif (types.size() == 1) {\n\t\t\t\treturn types.values().iterator().next();\n\t\t\t}\n\t\t\telse if (types.isEmpty()) {\n\t\t\t\tthrow new ReportableException(\"No type found with build '\" + this.build + \"' and format '\" + this.format\n\t\t\t\t\t\t+ \"' check the service capabilities (--list)\");\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new ReportableException(\"Multiple types found with build '\" + this.build + \"' and format '\"\n\t\t\t\t\t\t+ this.format + \"' use --type with a more specific value \" + types.keySet());\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tProjectType defaultType = metadata.getDefaultType();\n\t\t\tif (defaultType == null) {\n\t\t\t\tthrow new ReportableException((\"No project type is set and no default is defined. \"\n\t\t\t\t\t\t+ \"Check the service capabilities (--list)\"));\n\t\t\t}\n\t\t\treturn defaultType;\n\t\t}\n\t}\n\n\t/**\n\t * Resolve the artifactId to use or {@code null} if it should not be customized.\n\t * @return the artifactId\n\t */\n\tprotected @Nullable String resolveArtifactId() {","sourceCodeStart":371,"sourceCodeEnd":407,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/5b2dbdbb8be64415eb6552f81ff7c449c8d251e6/cli/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java#L371-L407","documentation":"Thrown in detectType mode when filtering by --build and --format leaves more than one candidate ProjectType. Because the CLI cannot choose between them, it reports the conflicting keys and asks the caller to disambiguate with an explicit --type.","triggerScenarios":"Calling `spring init --build <b> --format <f>` where the service advertises multiple types sharing the same build and format tags (e.g. several variants differing only by other tags). The error message includes types.keySet() listing the ambiguous ids.","commonSituations":"A service that exposes overlapping type definitions (e.g. a default and a 'sticky' variant with identical build/format); a custom Initializr with non-unique tag combinations; partial flags that intentionally match a family of types.","solutions":["Read the keys listed in the error message and pass the exact one via --type.","Add another distinguishing flag (e.g. --packaging) only if the service tags types by it; otherwise --type is required.","Run `spring init --list` to inspect the full tag set and pick the unambiguous type id."],"exampleFix":"// before\n$ spring init --build maven --format project\n  -> Multiple types found ... use --type ... [maven-project, maven-project-sticky]\n// after\n$ spring init --type maven-project myapp","handlingStrategy":"validation","validationCode":"List<String> matches = metadata.getProjectTypes().entrySet().stream()\n    .filter(e -> Objects.equals(request.getBuild(),  e.getValue().getTags().get(\"build\")))\n    .filter(e -> Objects.equals(request.getFormat(), e.getValue().getTags().get(\"format\")))\n    .map(Map.Entry::getKey).toList();\nif (matches.size() > 1) {\n    throw new IllegalStateException(\"Ambiguous type; choose one: \" + matches);\n}","typeGuard":"// Narrow to exactly one type before calling generateUrl\nlong n = metadata.getProjectTypes().values().stream()\n    .filter(t -> Objects.equals(request.getBuild(), t.getTags().get(\"build\")))\n    .filter(t -> Objects.equals(request.getFormat(), t.getTags().get(\"format\")))\n    .count();\nboolean unambiguous = (n == 1);","tryCatchPattern":"try { request.generateUrl(metadata); }\ncatch (ReportableException ex) {\n    if (ex.getMessage().startsWith(\"Multiple types found\")) {\n        // parse keys, ask user to pick, then setType(chosen) and retry\n    } else throw ex;\n}","preventionTips":["Pass --type whenever the build/format pair might match multiple variants.","Review --list output for overlapping types before scripting.","Treat ambiguity as a signal to pin the type explicitly."],"tags":["spring-boot-cli","initializr","project-generation","configuration"],"analyzedSha":"5b2dbdbb8be64415eb6552f81ff7c449c8d251e6","analyzedAt":"2026-08-04T18:53:14.967Z","schemaVersion":2}