{"record":{"id":"abb02e3dca28e29c","repo":"spring-projects/spring-boot","slug":"could-not-save-the-project-the-server-did-not-set","errorCode":null,"errorMessage":"Could not save the project, the server did not set a preferred file name and no location was set. Specify the output location for the project.","messagePattern":"Could not save the project, the server did not set a preferred file name and no location was set\\. Specify the output location for the project\\.","errorType":"exception","errorClass":"ReportableException","httpStatus":null,"severity":"error","filePath":"cli/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerator.java","lineNumber":63,"sourceCode":"\t\tthis.initializrService = initializrService;\n\t}\n\n\tvoid generateProject(ProjectGenerationRequest request, boolean force) throws IOException {\n\t\tProjectGenerationResponse response = this.initializrService.generate(request);\n\t\tString fileName = (request.getOutput() != null) ? request.getOutput() : response.getFileName();\n\t\tif (shouldExtract(request, response)) {\n\t\t\tif (isZipArchive(response)) {\n\t\t\t\textractProject(response, request.getOutput(), force);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tLog.info(\"Could not extract '\" + response.getContentType() + \"'\");\n\t\t\t\t// Use value from the server since we can't extract it\n\t\t\t\tfileName = response.getFileName();\n\t\t\t}\n\t\t}\n\t\tif (fileName == null) {\n\t\t\tthrow new ReportableException(\"Could not save the project, the server did not set a preferred \"\n\t\t\t\t\t+ \"file name and no location was set. Specify the output location for the project.\");\n\t\t}\n\t\twriteProject(response, fileName, force);\n\t}\n\n\t/**\n\t * Detect if the project should be extracted.\n\t * @param request the generation request\n\t * @param response the generation response\n\t * @return if the project should be extracted\n\t */\n\tprivate boolean shouldExtract(ProjectGenerationRequest request, ProjectGenerationResponse response) {\n\t\tif (request.isExtract()) {\n\t\t\treturn true;\n\t\t}\n\t\t// explicit name hasn't been provided for an archive and there is no extension\n\t\treturn isZipArchive(response) && request.getOutput() != null && !request.getOutput().contains(\".\");\n\t}","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/270dfe353fb830fd69b823a8a859287ff103854b/cli/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerator.java#L45-L81","documentation":"Thrown by ProjectGenerator.generateProject when no output file name can be determined: the response was not a zip to extract (or was not extractable), the server set no Content-Disposition preferred file name, and the user supplied no --output location. With nothing to write to, generation aborts.","triggerScenarios":"Server returns a non-zip content type with no Content-Disposition header and the user did not pass --output.","commonSituations":"Server misconfiguration dropping the Content-Disposition header; a non-standard Initializr endpoint; a request whose type/format yields a non-archive response.","solutions":["Pass --output with an explicit file path and name","Verify the service returns a Content-Disposition header","Ensure the requested type/format yields a zip if you expect extraction"],"exampleFix":"// before\n$ spring init\n// after\n$ spring init --output myapp.zip","handlingStrategy":"validation","validationCode":"// Ensure an output location is set before generating.\nif (request.getOutput() == null) {\n    request.setOutput(\"project.zip\"); // explicit fallback name\n}\n// Also sanity-check the response has a content type you can handle.","typeGuard":null,"tryCatchPattern":"try {\n    generator.generateProject(request, force);\n} catch (ReportableException ex) {\n    if (ex.getMessage().startsWith(\"Could not save the project\")) {\n        Log.error(\"No output file name - rerun with --output <path>\");\n    }\n    throw ex;\n}","preventionTips":["Always pass --output in automation so file naming does not depend on the server","Verify the service returns a Content-Disposition header for non-zip responses","Prefer zip-extractable types so the file name is not required"],"tags":["initializr","file-output","validation","configuration","spring-boot-cli"],"backgroundTag":null,"analyzedSha":"270dfe353fb830fd69b823a8a859287ff103854b","analyzedAt":"2026-08-11T19:42:06.541Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}