alibaba/spring-ai-alibaba · error · IllegalArgumentException

unknown dify app mode${map.get("mode")}

Error message

unknown dify app mode${map.get("mode")}

What it means

Thrown by DifyDSLAdapter.mapToMetadata when app.mode is not one of the recognized chatbot modes (DIFY_CHATBOT_MODES) nor workflow modes (DIFY_WORKFLOW_MODES). Dify supports several app modes; this adapter only maps the ones it can convert, and rejects anything else rather than guessing. Note the message concatenates the mode without a separator, e.g. 'unknown dify app modecompletion'.

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/dsl/adapters/DifyDSLAdapter.java:95

	}

	@Override
	public Serializer getSerializer() {
		return serializer;
	}

	@Override
	public AppMetadata mapToMetadata(Map<String, Object> data) {
		Map<String, Object> map = (Map<String, Object>) data.get("app");
		AppMetadata metadata = new AppMetadata();
		if (Arrays.asList(DIFY_CHATBOT_MODES).contains((String) map.get("mode"))) {
			metadata.setMode(AppMetadata.CHATBOT_MODE);
		}
		else if (Arrays.asList(DIFY_WORKFLOW_MODES).contains((String) map.get("mode"))) {
			metadata.setMode(AppMetadata.WORKFLOW_MODE);
		}
		else {
			throw new IllegalArgumentException("unknown dify app mode" + map.get("mode"));
		}
		metadata.setId(UUID.randomUUID().toString());
		metadata.setName((String) map.getOrDefault("name", metadata.getMode() + "-" + metadata.getId()));
		metadata.setDescription((String) map.getOrDefault("description", ""));
		return metadata;
	}

	@Override
	public Map<String, Object> metadataToMap(AppMetadata metadata) {
		Map<String, Object> data = new HashMap<>();
		String difyMode = metadata.getMode().equals(AppMetadata.WORKFLOW_MODE) ? "workflow" : "agent-chat";
		data.put("app", Map.of("name", metadata.getName(), "description", metadata.getDescription(), "mode", difyMode));
		data.put("kind", "app");
		return data;
	}

	@Override
	public Workflow mapToWorkflow(Map<String, Object> data) {

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Check the mode string in the Dify export's app.mode and change it to a supported chatbot or workflow mode
  2. Upgrade spring-ai-alibaba-admin to a version whose DIFY_*_MODES arrays cover your app's mode
  3. Convert the app in Dify to a chatbot or workflow type before exporting
  4. If the mode is genuinely unsupported, transform the DSL manually into a workflow-mode export

Example fix

// before (unsupported mode)
"app": {"mode": "completion", ...}

// after
"app": {"mode": "chat", ...}
Defensive patterns

Strategy: validation

Validate before calling

String mode = (String) ((Map<String,Object>) dslData.get("app")).get("mode");
Set<String> supported = Set.of("chat", "chatbot", "workflow", "advanced-chat"); // align with DIFY_*_MODES
if (mode == null || !supported.contains(mode)) {
    throw new IllegalArgumentException("Unsupported Dify app mode: " + mode);
}

Type guard

boolean isSupportedDifyMode(Object appObj) { return appObj instanceof Map<?,?> app && app.get("mode") instanceof String m && (m.equals("chat") || m.equals("workflow")); }

Try / catch

try { difyAdapter.importDSL(dslData); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("unknown dify app mode")) { String mode = e.getMessage().replace("unknown dify app mode", ""); log.error("Dify mode '{}' not supported by this adapter version; upgrade or convert the app", mode); } throw e; }

Prevention

When it happens

Trigger: Importing a Dify export whose app.mode is 'completion', 'agent-chat', or any mode string not present in DIFY_CHATBOT_MODES/DIFY_WORKFLOW_MODES arrays; mode missing entirely (null appended into message); importing a newer Dify export format that introduced new mode names.

Common situations: Dify version drift: newer Dify instances export modes this adapter version does not know; users exporting 'completion' (text-generator) or 'agent' apps expecting conversion; typos when hand-authoring mode.

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/8e8e110fa40e9488. Report an issue: GitHub.