spring-projects/spring-boot · error · ReportableException
Invalid content received from server ({})
Error message
Invalid content received from server ({}) What it means
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.
Source
Thrown at cli/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrService.java:140
Object loadServiceCapabilities(String serviceUrl) throws IOException {
HttpGet request = new HttpGet(serviceUrl);
request.setHeader(new BasicHeader(HttpHeaders.ACCEPT, ACCEPT_SERVICE_CAPABILITIES));
ClassicHttpResponse httpResponse = execute(request, URI.create(serviceUrl), "retrieve help");
validateResponse(httpResponse, serviceUrl);
HttpEntity httpEntity = httpResponse.getEntity();
ContentType contentType = ContentType.create(httpEntity.getContentType());
if (contentType.getMimeType().equals("text/plain")) {
return getContent(httpEntity);
}
return parseJsonMetadata(httpEntity);
}
private InitializrServiceMetadata parseJsonMetadata(HttpEntity httpEntity) throws IOException {
try {
return new InitializrServiceMetadata(getContentAsJson(httpEntity));
}
catch (JSONException ex) {
throw new ReportableException("Invalid content received from server (" + ex.getMessage() + ")", ex);
}
}
private void validateResponse(ClassicHttpResponse httpResponse, String serviceUrl) {
if (httpResponse.getEntity() == null) {
throw new ReportableException("No content received from server '" + serviceUrl + "'");
}
if (httpResponse.getCode() != 200) {
throw createException(serviceUrl, httpResponse);
}
}
private ProjectGenerationResponse createResponse(ClassicHttpResponse httpResponse, HttpEntity httpEntity)
throws IOException {
ProjectGenerationResponse response = new ProjectGenerationResponse(
ContentType.create(httpEntity.getContentType()));
response.setContent(FileCopyUtils.copyToByteArray(httpEntity.getContent()));
String fileName = extractFileName(httpResponse.getFirstHeader("Content-Disposition"));View on GitHub (pinned to 270dfe353f)
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
Example fix
// before $ spring init --target https://example.com foo // after $ spring init --target https://start.spring.io foo
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight: confirm the endpoint serves JSON metadata before generating. // `spring init --list --target <url>` exercises the same parse path cheaply. // In code, fetch the URL and assert content-type is application/json or // the body parses as a org.json.JSONObject before handing off to InitializrService.
Try / catch
try {
InitializrServiceMetadata metadata = service.loadMetadata(serviceUrl);
} catch (ReportableException ex) {
if (ex.getMessage().startsWith("Invalid content received from server")) {
Log.error("Not a valid Initializr endpoint: " + serviceUrl);
}
throw ex;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No content received from server '{}'
- Initializr service call failed using '{}' - service returned
- Failed to {} from service at '{}' ({})
- Invalid service URL ({})
- No project type with id '{}' - check the service capabilitie
AI-assisted analysis of spring-projects/spring-boot@270dfe353f (2026-08-11).
Data as JSON: /api/errors/56b79a9f4077b35b.
Report an issue: GitHub.