{"record":{"id":"56b79a9f4077b35b","repo":"spring-projects/spring-boot","slug":"invalid-content-received-from-server","errorCode":null,"errorMessage":"Invalid content received from server ({})","messagePattern":"Invalid content received from server \\((.+?)\\)","errorType":"exception","errorClass":"ReportableException","httpStatus":null,"severity":"error","filePath":"cli/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrService.java","lineNumber":140,"sourceCode":"\tObject loadServiceCapabilities(String serviceUrl) throws IOException {\n\t\tHttpGet request = new HttpGet(serviceUrl);\n\t\trequest.setHeader(new BasicHeader(HttpHeaders.ACCEPT, ACCEPT_SERVICE_CAPABILITIES));\n\t\tClassicHttpResponse httpResponse = execute(request, URI.create(serviceUrl), \"retrieve help\");\n\t\tvalidateResponse(httpResponse, serviceUrl);\n\t\tHttpEntity httpEntity = httpResponse.getEntity();\n\t\tContentType contentType = ContentType.create(httpEntity.getContentType());\n\t\tif (contentType.getMimeType().equals(\"text/plain\")) {\n\t\t\treturn getContent(httpEntity);\n\t\t}\n\t\treturn parseJsonMetadata(httpEntity);\n\t}\n\n\tprivate InitializrServiceMetadata parseJsonMetadata(HttpEntity httpEntity) throws IOException {\n\t\ttry {\n\t\t\treturn new InitializrServiceMetadata(getContentAsJson(httpEntity));\n\t\t}\n\t\tcatch (JSONException ex) {\n\t\t\tthrow new ReportableException(\"Invalid content received from server (\" + ex.getMessage() + \")\", ex);\n\t\t}\n\t}\n\n\tprivate void validateResponse(ClassicHttpResponse httpResponse, String serviceUrl) {\n\t\tif (httpResponse.getEntity() == null) {\n\t\t\tthrow new ReportableException(\"No content received from server '\" + serviceUrl + \"'\");\n\t\t}\n\t\tif (httpResponse.getCode() != 200) {\n\t\t\tthrow createException(serviceUrl, httpResponse);\n\t\t}\n\t}\n\n\tprivate ProjectGenerationResponse createResponse(ClassicHttpResponse httpResponse, HttpEntity httpEntity)\n\t\t\tthrows IOException {\n\t\tProjectGenerationResponse response = new ProjectGenerationResponse(\n\t\t\t\tContentType.create(httpEntity.getContentType()));\n\t\tresponse.setContent(FileCopyUtils.copyToByteArray(httpEntity.getContent()));\n\t\tString fileName = extractFileName(httpResponse.getFirstHeader(\"Content-Disposition\"));","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/270dfe353fb830fd69b823a8a859287ff103854b/cli/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrService.java#L122-L158","documentation":"Thrown by InitializrService.parseJsonMetadata when the server's HTTP 200 body cannot be parsed into InitializrServiceMetadata (a JSONException escapes). The server returned a successful status but the body was not valid JSON metadata or did not match the expected schema.","triggerScenarios":"The metadata URL (--target) points at a non-Initializr endpoint that returns 200 with HTML or malformed JSON; a proxy or captive portal injects a non-JSON page; the server emits JSON the CLI's metadata parser rejects.","commonSituations":"Wrong --target URL pointing at a plain web page; captive-portal or corporate proxy interception; an outdated CLI talking to a server with a changed metadata schema.","solutions":["Verify the --target URL is a real Spring Initializr service by opening it in a browser","Check for proxy or captive-portal interception of the request","Upgrade spring-boot-cli to match the server version","Point --target at https://start.spring.io to confirm"],"exampleFix":"// before\n$ spring init --target https://example.com foo\n// after\n$ spring init --target https://start.spring.io foo","handlingStrategy":"try-catch","validationCode":"// Pre-flight: confirm the endpoint serves JSON metadata before generating.\n// `spring init --list --target <url>` exercises the same parse path cheaply.\n// In code, fetch the URL and assert content-type is application/json or\n// the body parses as a org.json.JSONObject before handing off to InitializrService.","typeGuard":null,"tryCatchPattern":"try {\n    InitializrServiceMetadata metadata = service.loadMetadata(serviceUrl);\n} catch (ReportableException ex) {\n    if (ex.getMessage().startsWith(\"Invalid content received from server\")) {\n        Log.error(\"Not a valid Initializr endpoint: \" + serviceUrl);\n    }\n    throw ex;\n}","preventionTips":["Point --target only at known Initializr services","Open the metadata URL in a browser to eyeball the JSON before scripting","Upgrade the CLI when the server is upgraded"],"tags":["network","json","initializr","server-response","spring-boot-cli"],"backgroundTag":null,"analyzedSha":"270dfe353fb830fd69b823a8a859287ff103854b","analyzedAt":"2026-08-11T19:42:06.541Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}