alibaba/spring-ai-alibaba · error · InvalidProjectRequestException

Unknown type '${type}' check project metadata

Error message

Unknown type '${type}' check project metadata

What it means

validateType() looks up the requested project type (e.g. maven-build, gradle-build) in the Initializr metadata's registered types. If the id is not present, an InvalidProjectRequestException('Unknown type ... check project metadata') is thrown. Only type ids declared in the initializr metadata are accepted.

Source

Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/builder/generator/service/generator/GraphProjectReqToDescConverter.java:139

		validateLanguage(request.getLanguage(), metadata);
		validatePackaging(request.getPackaging(), metadata);
		validateDependencies(request, metadata);
	}

	private void validatePlatformVersion(ProjectRequest request, InitializrMetadata metadata) {
		Version platformVersion = Version.safeParse(request.getBootVersion());
		InitializrConfiguration.Platform platform = metadata.getConfiguration().getEnv().getPlatform();
		if (platformVersion != null && !platform.isCompatibleVersion(platformVersion)) {
			throw new InvalidProjectRequestException("Invalid Spring Boot version '" + platformVersion
					+ "', Spring Boot compatibility range is " + platform.determineCompatibilityRangeRequirement());
		}
	}

	private void validateType(String type, InitializrMetadata metadata) {
		if (type != null) {
			Type typeFromMetadata = metadata.getTypes().get(type);
			if (typeFromMetadata == null) {
				throw new InvalidProjectRequestException("Unknown type '" + type + "' check project metadata");
			}
			if (!typeFromMetadata.getTags().containsKey("build")) {
				throw new InvalidProjectRequestException(
						"Invalid type '" + type + "' (missing build tag) check project metadata");
			}
		}
	}

	private void validateLanguage(String language, InitializrMetadata metadata) {
		if (language != null) {
			DefaultMetadataElement languageFromMetadata = metadata.getLanguages().get(language);
			if (languageFromMetadata == null) {
				throw new InvalidProjectRequestException("Unknown language '" + language + "' check project metadata");
			}
		}
	}

	private void validatePackaging(String packaging, InitializrMetadata metadata) {

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Use a registered type id such as 'maven-build' or 'gradle-build' (query the generator's metadata endpoint to list valid ids)
  2. Register the custom type in the initializr metadata configuration (initializr.types in application.yml)
  3. Fix the typo in the calling code or HTTP request parameter

Example fix

// before
request.setType("mave-build");
// after
request.setType("maven-build");
Defensive patterns

Strategy: validation

Validate before calling

if (type != null && !Set.of("maven-build","gradle-build").contains(type)) {
    throw new IllegalArgumentException("type '" + type + "' not registered in metadata");
}

Try / catch

try {
    converter.validate(request);
} catch (InvalidProjectRequestException e) {
    return ResponseEntity.badRequest().body(e.getMessage());
}

Prevention

When it happens

Trigger: Calling validate/convert with ProjectRequest type set to an id not present in metadata.getTypes() — e.g. type 'ant' or a typo like 'mave-build'.

Common situations: Typos in the type parameter, client sending a type from a different initializr instance, custom types not registered in the admin service's initializr metadata configuration.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09). Data as JSON: /api/errors/106f677e003eb8de. Report an issue: GitHub.