{"id":"a1837c97d93d2ccf","repo":"spring-projects/spring-boot","slug":"no-project-type-is-set-and-no-default-is-defined","errorCode":null,"errorMessage":"No project type is set and no default is defined. Check the service capabilities (--list)","messagePattern":"No project type is set and no default is defined\\. Check the service capabilities \\(--list\\)","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":396,"sourceCode":"\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() {\n\t\tif (this.artifactId != null) {\n\t\t\treturn this.artifactId;\n\t\t}\n\t\tif (this.output != null) {\n\t\t\tint i = this.output.lastIndexOf('.');\n\t\t\treturn (i != -1) ? this.output.substring(0, i) : this.output;\n\t\t}","sourceCodeStart":378,"sourceCodeEnd":414,"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#L378-L414","documentation":"Thrown when no --type was set, detectType is not active, and the Initializr service metadata reports no default project type (InitializrServiceMetadata.getDefaultType() returns null). The CLI has no way to pick a type and aborts rather than send an untyped request.","triggerScenarios":"Invoking `spring init` with neither --type nor (--build/--format with detectType) against a service whose metadata has no 'default' type entry. Typical of a minimal or misconfigured Initializr instance, or a service whose metadata payload was altered/filtered.","commonSituations":"Using a custom/private Initializr that didn't set a default type; service metadata partially unavailable due to a proxy returning an error page instead of JSON; pointing at the wrong URL so metadata parsing yields an empty type map.","solutions":["Run `spring init --list` against the same --target to confirm what (if anything) the service advertises.","Always pass an explicit --type so generation does not depend on a server default.","Verify --target points to a working Initializr (default https://start.spring.io) and that network/proxy isn't intercepting the metadata response."],"exampleFix":"// before\n$ spring init --target https://internal-start/ myapp\n  -> No project type is set and no default is defined\n// after\n$ spring init --target https://internal-start/ --list   # inspect capabilities\n$ spring init --target https://internal-start/ --type maven-project myapp","handlingStrategy":"validation","validationCode":"InitializrServiceMetadata md = InitializrServiceMetadata.forService(request.getServiceUrl());\nif (request.getType() == null && !request.isDetectType() && md.getDefaultType() == null) {\n    throw new IllegalStateException(\n        \"Service \" + request.getServiceUrl() + \" has no default type; set --type explicitly.\");\n}","typeGuard":"boolean safeToGenerate = request.getType() != null\n    || request.isDetectType()\n    || metadata.getDefaultType() != null;","tryCatchPattern":"try { request.generateUrl(metadata); }\ncatch (ReportableException ex) {\n    if (ex.getMessage().contains(\"no default is defined\")) {\n        // require user to pass --type or switch --target to a fuller service\n    } else throw ex;\n}","preventionTips":["Always specify --type in automation so generation never depends on a server default.","Validate --target reaches a real Initializr (check the metadata response is JSON, not an error page).","Cache/inspect metadata once per service to confirm it exposes a default type."],"tags":["spring-boot-cli","initializr","project-generation","configuration"],"analyzedSha":"5b2dbdbb8be64415eb6552f81ff7c449c8d251e6","analyzedAt":"2026-08-04T18:53:14.967Z","schemaVersion":2}