spring-projects/spring-boot · error · ReportableException

Invalid service URL ({})

Error message

Invalid service URL ({})

What it means

Thrown by ProjectGenerationRequest.generateUrl() when constructing the full request URI raises a URISyntaxException. The base service URL plus query parameters (groupId, artifactId, version, javaVersion, bootVersion, language, etc.) must form a valid URI; any unencodable component fails.

Source

Thrown at cli/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java:360

				builder.setParameter("type", projectType.getId());
			}
			if (this.packaging != null) {
				builder.setParameter("packaging", this.packaging);
			}
			if (this.javaVersion != null) {
				builder.setParameter("javaVersion", this.javaVersion);
			}
			if (this.language != null) {
				builder.setParameter("language", this.language);
			}
			if (this.bootVersion != null) {
				builder.setParameter("bootVersion", this.bootVersion);
			}

			return builder.build();
		}
		catch (URISyntaxException ex) {
			throw new ReportableException("Invalid service URL (" + ex.getMessage() + ")");
		}
	}

	protected ProjectType determineProjectType(InitializrServiceMetadata metadata) {
		if (this.type != null) {
			ProjectType result = metadata.getProjectTypes().get(this.type);
			if (result == null) {
				throw new ReportableException(
						("No project type with id '" + this.type + "' - check the service capabilities (--list)"));
			}
			return result;
		}
		else if (isDetectType()) {
			Map<String, ProjectType> types = new HashMap<>(metadata.getProjectTypes());
			if (this.build != null) {
				filter(types, "build", this.build);
			}
			if (this.format != null) {

View on GitHub (pinned to 270dfe353f)

Solutions

  1. Quote shell arguments containing special characters
  2. Sanitize groupId/artifactId to Maven-friendly values (lowercase, no spaces)
  3. Validate the --target URL has a scheme and host (e.g. https://host)

Example fix

// before
$ spring init -a 'my artifact'
// after
$ spring init -a my-artifact
Defensive patterns

Strategy: validation

Validate before calling

// Validate each component before the request builds its URI.
String artifactId = request.getArtifactId();
if (artifactId != null && !artifactId.matches("[a-zA-Z][a-zA-Z0-9_-]*")) {
    throw new IllegalArgumentException("artifactId must be URI-safe: " + artifactId);
}
new java.net.URI(request.getTarget()); // throws early on a malformed base URL

Try / catch

try {
    request.generateUrl();
} catch (ReportableException ex) {
    if (ex.getMessage().startsWith("Invalid service URL")) {
        Log.error("A parameter made the URL invalid - check artifactId/groupId/target");
    }
    throw ex;
}

Prevention

When it happens

Trigger: A project parameter contains characters that break the URI (raw spaces, control characters) that are not being encoded; or the --target base URL is itself malformed (missing scheme or host).

Common situations: Passing a groupId/artifactId with spaces or shell-special characters without quoting; a --target URL missing its scheme or host.

Related errors


AI-assisted analysis of spring-projects/spring-boot@270dfe353f (2026-08-11). Data as JSON: /api/errors/3c561af181802972. Report an issue: GitHub.