{"record":{"id":"8e8e110fa40e9488","repo":"alibaba/spring-ai-alibaba","slug":"unknown-dify-app-mode-map-get-mode","errorCode":null,"errorMessage":"unknown dify app mode${map.get(\"mode\")}","messagePattern":"unknown dify app mode(.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"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","lineNumber":95,"sourceCode":"\t}\n\n\t@Override\n\tpublic Serializer getSerializer() {\n\t\treturn serializer;\n\t}\n\n\t@Override\n\tpublic AppMetadata mapToMetadata(Map<String, Object> data) {\n\t\tMap<String, Object> map = (Map<String, Object>) data.get(\"app\");\n\t\tAppMetadata metadata = new AppMetadata();\n\t\tif (Arrays.asList(DIFY_CHATBOT_MODES).contains((String) map.get(\"mode\"))) {\n\t\t\tmetadata.setMode(AppMetadata.CHATBOT_MODE);\n\t\t}\n\t\telse if (Arrays.asList(DIFY_WORKFLOW_MODES).contains((String) map.get(\"mode\"))) {\n\t\t\tmetadata.setMode(AppMetadata.WORKFLOW_MODE);\n\t\t}\n\t\telse {\n\t\t\tthrow new IllegalArgumentException(\"unknown dify app mode\" + map.get(\"mode\"));\n\t\t}\n\t\tmetadata.setId(UUID.randomUUID().toString());\n\t\tmetadata.setName((String) map.getOrDefault(\"name\", metadata.getMode() + \"-\" + metadata.getId()));\n\t\tmetadata.setDescription((String) map.getOrDefault(\"description\", \"\"));\n\t\treturn metadata;\n\t}\n\n\t@Override\n\tpublic Map<String, Object> metadataToMap(AppMetadata metadata) {\n\t\tMap<String, Object> data = new HashMap<>();\n\t\tString difyMode = metadata.getMode().equals(AppMetadata.WORKFLOW_MODE) ? \"workflow\" : \"agent-chat\";\n\t\tdata.put(\"app\", Map.of(\"name\", metadata.getName(), \"description\", metadata.getDescription(), \"mode\", difyMode));\n\t\tdata.put(\"kind\", \"app\");\n\t\treturn data;\n\t}\n\n\t@Override\n\tpublic Workflow mapToWorkflow(Map<String, Object> data) {","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/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#L77-L113","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the mode string in the Dify export's app.mode and change it to a supported chatbot or workflow mode","Upgrade spring-ai-alibaba-admin to a version whose DIFY_*_MODES arrays cover your app's mode","Convert the app in Dify to a chatbot or workflow type before exporting","If the mode is genuinely unsupported, transform the DSL manually into a workflow-mode export"],"exampleFix":"// before (unsupported mode)\n\"app\": {\"mode\": \"completion\", ...}\n\n// after\n\"app\": {\"mode\": \"chat\", ...}","handlingStrategy":"validation","validationCode":"String mode = (String) ((Map<String,Object>) dslData.get(\"app\")).get(\"mode\");\nSet<String> supported = Set.of(\"chat\", \"chatbot\", \"workflow\", \"advanced-chat\"); // align with DIFY_*_MODES\nif (mode == null || !supported.contains(mode)) {\n    throw new IllegalArgumentException(\"Unsupported Dify app mode: \" + mode);\n}","typeGuard":"boolean isSupportedDifyMode(Object appObj) { return appObj instanceof Map<?,?> app && app.get(\"mode\") instanceof String m && (m.equals(\"chat\") || m.equals(\"workflow\")); }","tryCatchPattern":"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; }","preventionTips":["Convert non-chatbot/non-workflow Dify apps (completion, agent) to chatbot or workflow before exporting","Keep spring-ai-alibaba-admin updated for new Dify mode names","Check app.mode in the export before import","Log the parsed mode value to catch null/missing modes early"],"tags":["dify","unsupported-value","import"],"backgroundTag":"invalid-enum-value","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}