alibaba/spring-ai-alibaba · error · InvalidProjectRequestException

Unknown packaging '${packaging}' check project metadata

Error message

Unknown packaging '${packaging}' check project metadata

What it means

validatePackaging() verifies the requested packaging id (e.g. jar, war) exists in the Initializr metadata's packagings. If not found, an InvalidProjectRequestException('Unknown packaging ... check project metadata') is thrown. Only packaging ids registered in metadata.getPackagings() are valid.

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:161

						"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) {
		if (packaging != null) {
			DefaultMetadataElement packagingFromMetadata = metadata.getPackagings().get(packaging);
			if (packagingFromMetadata == null) {
				throw new InvalidProjectRequestException(
						"Unknown packaging '" + packaging + "' check project metadata");
			}
		}
	}

	private void validateDependencies(ProjectRequest request, InitializrMetadata metadata) {
		List<String> dependencies = request.getDependencies();
		dependencies.forEach((dep) -> {
			Dependency dependency = metadata.getDependencies().get(dep);
			if (dependency == null) {
				throw new InvalidProjectRequestException("Unknown dependency '" + dep + "' check project metadata");
			}
		});
	}

	private void validateDependencyRange(Version platformVersion, List<Dependency> resolvedDependencies) {
		resolvedDependencies.forEach((dep) -> {
			if (!dep.match(platformVersion)) {

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Use a registered packaging id such as 'jar' or 'war'
  2. Register the packaging in the initializr metadata configuration (initializr.packagings)
  3. Correct the typo in the caller

Example fix

// before
request.setPackaging("jarr");
// after
request.setPackaging("jar");
Defensive patterns

Strategy: validation

Validate before calling

if (packaging != null && !Set.of("jar","war").contains(packaging)) {
    throw new IllegalArgumentException("packaging '" + packaging + "' not registered");
}

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 packaging set to an unregistered id — e.g. packaging 'ear' or a typo like 'jarr'.

Common situations: Typos in packaging parameter, clients expecting war support when only jar is registered, custom packaging values not added to initializr metadata.

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/91f016a4dc3913c2. Report an issue: GitHub.