alibaba/spring-ai-alibaba · error · IllegalArgumentException

The current mode does not support Studio's knowledge retriev

Error message

The current mode does not support Studio's knowledge retrieval node code generation. Please start the complete StudioApplication class

What it means

KnowledgeRetrievalNodeSection.render requires studioDocumentService and studioStoragePath when generating code for a STUDIO-dialect knowledge retrieval node. When running a partial/test application where these beans/fields are null, it throws IllegalArgumentException telling the user to start the full StudioApplication class. Studio knowledge retrieval needs document storage access that only the complete application provides.

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/workflow/sections/KnowledgeRetrievalNodeSection.java:70

	// 用于获取Studio存储的文档
	private final DocumentService studioDocumentService;

	private final String studioStoragePath;

	public KnowledgeRetrievalNodeSection(@Autowired(required = false) DocumentService studioDocumentService,
			@Autowired(required = false) StudioProperties properties) {
		this.studioDocumentService = studioDocumentService;
		this.studioStoragePath = properties != null ? properties.getStoragePath() : null;
	}

	@Override
	public String render(Node node, String varName) {
		KnowledgeRetrievalNodeData nodeData = (KnowledgeRetrievalNodeData) node.getData();

		if (DSLDialectType.STUDIO.equals(nodeData.getDialectType())) {
			if (this.studioDocumentService == null || this.studioStoragePath == null) {
				throw new IllegalArgumentException(
						"The current mode does not support Studio's knowledge retrieval node code generation. Please start the complete StudioApplication class");
			}
			// 根据knowledgeBaseIds获取对应的资源文件
			List<ResourceFile> resourceFiles = Optional.ofNullable(nodeData.getKnowledgeBaseIds())
				.orElse(List.of())
				.stream()
				.map(kbId -> {
					PagingList<Document> getSize = this.studioDocumentService.listDocuments(kbId, new DocumentQuery());
					Long total = getSize.getTotal();
					DocumentQuery query = new DocumentQuery();
					query.setSize(total.intValue());
					PagingList<Document> pagingList = this.studioDocumentService.listDocuments(kbId, query);
					return pagingList.getRecords();
				})
				.flatMap(List::stream)
				.filter(Document::getEnabled)
				.filter(d -> StringUtils.hasText(d.getPath()))
				.map(document -> {

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Start the generator via the complete StudioApplication class as the message instructs.
  2. Verify the studioDocumentService bean is registered and studioStoragePath property is set in the active configuration.
  3. For STUDIO-dialect workflows in tests, mock/stub studioDocumentService and studioStoragePath, or switch the dialect to a non-STUDIO mode.

Example fix

// before
SpringApplication.run(SomeMinimalRunner.class);
// after
SpringApplication.run(StudioApplication.class); // full app wires DocumentService + storage path
Defensive patterns

Strategy: validation

Validate before calling

if (dialectType == DSLDialectType.STUDIO &&
    (studioDocumentService == null || studioStoragePath == null))
    throw new IllegalStateException("Start StudioApplication or provide DocumentService + storagePath");

Try / catch

try { generator.generate(spec); } catch (IllegalArgumentException e) { if (e.getMessage().contains("StudioApplication")) { /* relaunch with full app context */ } throw e; }

Prevention

When it happens

Trigger: Calling render on a KnowledgeRetrieval node with dialectType == DSLDialectType.STUDIO while studioDocumentService == null or studioStoragePath == null (e.g. generator used in a stripped-down main or unit test without the Studio beans wired).

Common situations: Running project generation from a minimal runner/test context instead of StudioApplication; beans conditionally not loaded due to missing profiles or component scan scope; storage path property not set in application config.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


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