alibaba/spring-ai-alibaba · error · IllegalArgumentException
invalid dify dsl
Error message
invalid dify dsl
What it means
Thrown by DifyDSLAdapter.validateDSLData when the provided DSL data is null or does not contain a top-level 'app' key. Dify exports always carry an 'app' object holding mode, name, and description, so its absence means the document is not a valid Dify DSL. This is the first gate before mode mapping and conversion.
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:75
/**
* DifyDSLAdapter converts Dify DSL to {@link App} and vice versa.
*/
@Component
public class DifyDSLAdapter extends AbstractDSLAdapter {
private static final String[] DIFY_CHATBOT_MODES = { "chat", "completion", "agent-chat" };
private static final String[] DIFY_WORKFLOW_MODES = { "workflow", "advanced-chat" };
public DifyDSLAdapter(List<NodeDataConverter<? extends NodeData>> nodeDataConverters,
@Qualifier("yaml") Serializer serializer) {
super(nodeDataConverters, serializer);
}
@Override
public void validateDSLData(Map<String, Object> dslData) {
if (dslData == null || !dslData.containsKey("app")) {
throw new IllegalArgumentException("invalid dify dsl");
}
}
@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);
}View on GitHub (pinned to f82da0b50f)
Solutions
- Pass the full Dify export document including its top-level 'app' object
- Verify you selected the DifyDSLAdapter for a Dify export (use Studio/Agent adapters for their own formats)
- Check YAML/JSON parsing did not drop or rename the 'app' key
- Log the parsed map keys before import to confirm structure
Example fix
// before
Map.of("mode", "chat", "name", "bot")
// after
Map.of("app", Map.of("mode", "chat", "name", "bot")) Defensive patterns
Strategy: validation
Validate before calling
if (dslData == null || !dslData.containsKey("app")) {
throw new IllegalArgumentException("not a valid Dify DSL: top-level 'app' object required");
} Type guard
boolean isDifyDsl(Map<String,Object> dsl) { return dsl != null && dsl.get("app") instanceof Map; } Try / catch
try { difyAdapter.importDSL(dslData); } catch (IllegalArgumentException e) { log.error("Dify DSL missing 'app': check file format"); throw e; } Prevention
- Import the complete Dify export document, not the inner app object
- Confirm the file is a Dify export before choosing the Dify adapter
- Check YAML/JSON parsing preserved the top-level 'app' key
When it happens
Trigger: Calling importDSL/validateDSLData with a null map; passing a DSL missing the 'app' key; passing a Spring AI Alibaba native or Studio DSL to the Dify adapter; passing only the inner app object rather than the wrapper containing it.
Common situations: Uploading the wrong file type (native DSL instead of a Dify YAML/JSON export); extracting the inner app object and passing it instead of the full document; YAML parsing that flattened the structure; automated pipelines mixing adapter inputs.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- invalid agent dsl: missing 'agent' object or flat agent fiel
- invalid agent dsl: 'type/agent_class' and 'name' are require
- invalid dsl
- ${type} requires valid configuration
- ${type} requires 'name' field
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/b86d95973798c342.
Report an issue: GitHub.