Failed importing dsl file, Error: Uncaught TypeError: Cannot read properties of undefined (reading 'length') #15655

Closed
opened 2026-02-21 19:22:44 -05:00 by yindo · 6 comments
Owner

Originally created by @mengze1320 on GitHub (Jul 24, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.5.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Here is the yml file:
app:
description: ''
icon: 🤖
icon_background: '#FFEAD5'
mode: advanced-chat
name: 招生问答网页版 (优化版)
use_icon_as_answer_icon: false
dependencies:

  • current_identifier: null
    type: marketplace
    value:
    marketplace_plugin_unique_identifier: langgenius/tongyi:0.0.27@4bb3f3eb6149b01f92aa6038a6bb074cc4224b8c015f54c888e5c5a30fc1ab50
    kind: app
    version: 0.3.0
    workflow:
    conversation_variables:
    • description: ''
      id: 0a7bd6e8-3c5f-4cf8-a075-1dbe144253e7
      name: exam_type
      selector:
      • conversation
      • exam_type
        value: ''
        value_type: string
    • description: ''
      id: dd3e134a-3905-49d1-96c3-b8cdf084aaac
      name: time
      selector:
      • conversation
      • time
        value: 2025
        value_type: number
    • description: 用于存储用户历史输入数据
      id: e8f0d784-a4ac-4515-84a0-4d632687be46
      name: conversation_histories
      selector:
      • conversation
      • conversation_histories
        value: []
        value_type: array[string]
        environment_variables: []
        features:
        file_upload:
        enabled: false
        opening_statement: ''
        retriever_resource:
        enabled: true
        sensitive_word_avoidance:
        enabled: false
        speech_to_text:
        enabled: false
        suggested_questions: []
        suggested_questions_after_answer:
        enabled: false
        text_to_speech:
        enabled: false
        graph:
        edges:
      • data: {}
        id: start-llm2
        source: 'start'
        sourceHandle: source
        target: 'llm_2_intent_check'
        targetHandle: target
      • data: {}
        id: llm2-if1
        source: 'llm_2_intent_check'
        sourceHandle: source
        target: 'if_else_1_is_complete'
        targetHandle: target
      • data: {}
        id: if1_true-llm1
        source: 'if_else_1_is_complete'
        sourceHandle: case_is_complete
        target: 'llm_1_query_rewrite'
        targetHandle: target
      • data: {}
        id: if1_false-answer_clarify
        source: 'if_else_1_is_complete'
        sourceHandle: 'false'
        target: 'answer_clarify_question'
        targetHandle: target
      • data: {}
        id: answer_clarify-assigner
        source: 'answer_clarify_question'
        sourceHandle: source
        target: 'assigner_1_store_history'
        targetHandle: target
      • data: {}
        id: if1_true-llm4
        source: 'if_else_1_is_complete'
        sourceHandle: case_is_complete
        target: 'llm_4_extract_vars'
        targetHandle: target
      • data: {}
        id: llm4-assigner2
        source: 'llm_4_extract_vars'
        sourceHandle: source
        target: 'assigner_2_store_vars'
        targetHandle: target
      • data: {}
        id: llm1-kr1
        source: 'llm_1_query_rewrite'
        sourceHandle: source
        target: 'kr_1_qna_retrieval'
        targetHandle: target
      • data: {}
        id: kr1-if2
        source: 'kr_1_qna_retrieval'
        sourceHandle: source
        target: 'if_else_2_is_kr1_found'
        targetHandle: target
      • data: {}
        id: if2_true-code1
        source: 'if_else_2_is_kr1_found'
        sourceHandle: 'true'
        target: 'code_1_extract_qna_answer'
        targetHandle: target
      • data: {}
        id: code1-answer1
        source: 'code_1_extract_qna_answer'
        sourceHandle: source
        target: 'answer_1_qna'
        targetHandle: target
      • data: {}
        id: if2_false-kr2
        source: 'if_else_2_is_kr1_found'
        sourceHandle: 'false'
        target: 'kr_2_doc_retrieval'
        targetHandle: target
      • data: {}
        id: kr2-llm3
        source: 'kr_2_doc_retrieval'
        sourceHandle: source
        target: 'llm_3_generate_answer'
        targetHandle: target
      • data: {}
        id: llm3-code2
        source: 'llm_3_generate_answer'
        sourceHandle: source
        target: 'code_2_format_final_output'
        targetHandle: target
      • data: {}
        id: kr2-code2
        source: 'kr_2_doc_retrieval'
        sourceHandle: source
        target: 'code_2_format_final_output'
        targetHandle: target
      • data: {}
        id: code2-answer2
        source: 'code_2_format_final_output'
        sourceHandle: source
        target: 'answer_2_final'
        targetHandle: target
        nodes:
      • data:
        title: 开始
        type: start
        id: 'start'
      • data:
        title: LLM 2 (需求分析引擎)
        desc: 判断用户意图是否完整,输出 'Completed' 或 'Incompleted' 状态。
        type: llm
        model:
        provider: langgenius/tongyi/tongyi
        name: qwen-plus
        mode: chat
        completion_params: {}
        prompt_template:
        • role: system
          text: "# 角色 你是一个专业的上海市教育政策咨询专家,同时也是一个高效的需求分析引擎。\n# 核心目标 你的唯一目标是分析用户输入和完整的对话历史,判断用户的核心诉求是否清晰,并通过一轮或多轮对话,最终明确用户的完整意图。\n\n#完整意图必要的信息清单\n-具体是什么考试类型:可能包括但不限于高考,中考,研究生考试、成人考试、同等学力考试,自学考试,证书考试\n-用户咨询的主题:可能包括命题、报名、考试、评卷、成绩、志愿填报、招生录取、个性化咨询等等\n-时间信息:哪一年的考试\n\n#工作流程与逻辑\n你必须像一个程序一样,严格遵循以下步骤:\n 1. 分析上下文: 首先,仔细检查完整的【对话历史】和用户的【最新输入】。 2. 核对清单: 根据分析结果,判断上述“信息清单”中的三要素哪些已经明确,哪些仍然缺失。 \n3. 判断状态: - 如果所有要素都已明确,当前状态为 "Completed"。 - 如果任一要素缺失,当前状态为 "Incompleted"。 \n4. 执行动作: \n- 若状态为 "Incompleted",请针对最关键的缺失信息,生成一句自然的、引导性的问题。\n - 若状态为 "Completed",请将已收集到的所有用户需求原话进行输出。\n\n# 关键规则 \n- 记忆能力: 你必须时刻检查【对话历史】,绝对不要重复提问用户已经给过的信息。\n- 自然对话: 你的提问要像一个真人专家,友好且自然。\n - 禁止泄露背景知识: 在“信息清单”中用于辅助你理解的考试分类(如春季高考、秋季高考、中考...)和主题分类(如命题、报名...),绝对不能以列表形式直接展示给用户。这些仅供你内部判断使用。\n- 严格的输出格式: 你的最终输出必须,也只能是一个JSON对象,不能包含任何额外的文字、解释或Markdown标记。\n\n# 输出格式\n你必须严格按照以下JSON格式输出,不要有任何多余的文字或解释。\n-如果信息完整,则status为Completed,并且将组合的用户咨询需求原话输出到content中\n{"status":"Completed",\n"content":[具体的用户咨询内容]}\n-如果信息不完整,则status为Incompleted,请自然地询问缺失的信息并且将问题输出到content中\n{"status":"Incompleted",\n"content":[下一个引导性提问]}"
        • role: user
          text: '用户的输入{{#sys.query#}}\n\n对话历史:{{#conversation.conversation_histories#}}'
          structured_output_enabled: true
          structured_output:
          schema:
          type: object
          properties:
          status:
          type: string
          description: "该字段用于表示用户咨询是否清晰明确,'Completed'或'Incompleted'"
          content:
          type: string
          description: "该字段用于输出大模型的引导性提问或者整理好的用户提问"
          id: 'llm_2_intent_check'
      • data:
        title: 条件分支 1
        desc: "判断用户意图是否完整"
        type: if-else
        cases:
        • case_id: case_is_complete
          conditions:
          • variable_selector:
            • 'llm_2_intent_check'
            • structured_output
            • status
              comparison_operator: is
              value: Completed
              id: 'if_else_1_is_complete'
      • data:
        title: 直接回复 (追问)
        type: answer
        answer: '{{#llm_2_intent_check.structured_output.content#}}'
        id: 'answer_clarify_question'
      • data:
        title: 变量赋值 1
        desc: "将当前用户提问存入历史记录"
        type: assigner
        items:
        • variable_selector:
          • conversation
          • conversation_histories
            operation: append
            input_type: variable
            value:
          • sys
          • query
            id: 'assigner_1_store_history'
      • data:
        title: LLM 1 (查询重写引擎)
        desc: 将零散对话转换成独立的、完整的、用于检索的正式问题。
        type: llm
        model:
        provider: langgenius/tongyi/tongyi
        name: qwen-plus
        mode: chat
        completion_params: {}
        prompt_template:
        • role: system
          text: "# 角色 你是一个专业的“查询重写”引擎,专门负责处理上海市教育招生考试领域的咨询。 \n# 核心目标 你的唯一任务是将用户在多轮对话中表达的、可能零散的意图,转换成一个独立的、语法完整的、可以直接用于数据库检索的正式问题。 \n# 关键规则 \n1. 转换而非描述: 你的输出必须是一个完整的问句,而不是一句描述用户意图的话(例如,严禁使用“用户想了解...”这样的句式)。 \n2. 信息融合: 你需要将对话中收集到的所有关键信息(如考试类型、年份、主题等)融合进这个最终的问句中。 \n3. 保持意图: 转换后的问题必须100%忠实于用户的原始意图,且必须要保持用户的原话,且保持用户的原始句式,保持原话,保持原话。 \n4.忠于事实: 重写后的问题不能凭空捏造或添加原对话中不存在的事实信息。\n5. 参考风格: 下面的例子展示了你输出的最终风格,你应该模仿这种**自包含(self-contained)**的问句格式。 \n# 转换后的用户咨询内容举例(输出风格参考):\n - "2025年本市高中阶段学校招生的录取总成绩由哪些考试科目构成?" \n - "2024年上海市初中学业水平考试的科目有哪些?分值是怎样设置的?"\n - "如何申请2025年硕士研究生招生考试的成绩复核?" \n- "普通高校专升本的报名条件和流程是什么?""
        • role: user
          text: '{{#llm_2_intent_check.structured_output.content#}}'
          id: 'llm_1_query_rewrite'
      • data:
        title: LLM 4 (信息提取)
        desc: 从重写后的问题中提取年份和考试类型。
        type: llm
        model:
        provider: langgenius/tongyi/tongyi
        name: qwen-plus
        mode: chat
        completion_params: {}
        prompt_template:
        • role: system
          text: "# 角色\n你是一个专门从文本中提取结构化信息的AI引擎。\n\n# 核心任务\n你的任务是仔细分析【用户查询】的文本,并从中提取出【时间信息】和【考试业务类型】这两个关键字段。然后,你必须严格按照预定义的JSON格式输出结果。\n\n# 字段提取规则\n1. time (number):\n - 如果文本中包含明确的四位数年份(如‘2025年’、‘2024’),请提取该年份并以【数字】格式输出。\n - 如果文本中没有明确的年份,但提到了“今年”、“明年”等相对时间,请统一输出【当前年份的四位数字】,例如 2025。\n - 如果文本完全不涉及时间信息,请按照2025年进行处理。\n\n2. exam_type (string):\n - 根据文本内容,判断其涉及的核心考试业务类型。\n - 你的判断应该基于一个预定义的分类(高考学考、中考招考、证书考试、自学考试、研考成考),但你只需要输出最终判断出的那个【字符串】结果。\n - 如果无法从文本中判断出具体的考试类型,请输出 null。\n\n# 输出格式\n你的输出必须是一个严格的、不包含任何额外解释或Markdown标记的JSON对象。\n\n# 示例\n---\n用户查询: "2024年上海市的自学考试报名流程。"\n你的输出:\n{\n "time": 2024,\n "exam_type": "自学考试"\n}\n---\n用户查询: "中考的体育考试总分是多少?"\n你的输出:\n{\n "time": 2025,\n "exam_type": "中考"\n}\n---\n\n用户查询: "你好"\n你的输出:\n{\n "time": null,\n "exam_type": null\n}\n---"
        • role: user
          text: '用户查询:{{#llm_1_query_rewrite.text#}}'
          structured_output_enabled: true
          structured_output:
          schema:
          type: object
          properties:
          time:
          type: number
          exam_type:
          type: string
          id: 'llm_4_extract_vars'
      • data:
        title: 变量赋值 2
        desc: "存储提取出的年份和考试类型"
        type: assigner
        items:
        • variable_selector:
          • conversation
          • time
            operation: over-write
            input_type: variable
            value:
          • 'llm_4_extract_vars'
          • structured_output
          • time
        • variable_selector:
          • conversation
          • exam_type
            operation: over-write
            input_type: variable
            value:
          • 'llm_4_extract_vars'
          • structured_output
          • exam_type
            id: 'assigner_2_store_vars'
      • data:
        title: 知识检索 1 (Q&A)
        desc: 第一层,高精度检索问答对知识库。
        type: knowledge-retrieval
        query_variable_selector:
        • 'llm_1_query_rewrite'
        • text
          dataset_ids:
        • cZUBZkC6zX4mN2T5LblosITl8SacjJD83sjq+rY+6xhWroBv43BCTaMPv/d6a8pN
          retrieval_mode: multiple
          multiple_retrieval_config:
          top_k: 1
          score_threshold: 0.8
          reranking_enable: false
          id: 'kr_1_qna_retrieval'
      • data:
        title: 条件分支 2
        desc: 判断第一层知识检索是否命中。
        type: if-else
        cases:
        • case_id: 'true'
          conditions:
          • variable_selector:
            • 'kr_1_qna_retrieval'
            • result
              comparison_operator: not empty
              id: 'if_else_2_is_kr1_found'
      • data:
        title: 代码执行 1
        desc: "从元数据中提取预设的标准答案"
        type: code
        code_language: python3
        variables:
        • variable: qna_result
          value_selector:
          • 'kr_1_qna_retrieval'
          • result
            outputs:
            answer:
            type: string
            code: |
            def main(qna_result: list) -> dict:
            if not qna_result:
            return {"answer": "抱歉,没有找到直接答案。"}
            return {
            "answer": qna_result[0].get('metadata', {}).get('doc_metadata', {}).get('answer', '未找到预设答案。')
            }
            id: 'code_1_extract_qna_answer'
      • data:
        title: 直接回复 1 (标准答案)
        type: answer
        answer: '{{#code_1_extract_qna_answer.answer#}}'
        id: 'answer_1_qna'
      • data:
        title: 知识检索 2 (文档)
        desc: 第二层,检索长文档知识库。
        type: knowledge-retrieval
        query_variable_selector:
        • 'llm_1_query_rewrite'
        • text
          dataset_ids:
        • mf3VS+yBGgWEFi1Ml+68wO/UlSH7iwUJ4mu/wLFG5lrs98hd8x8qKivgzbf9jQDP
        • "+JNSzYIb5ChVBeFPdNLuj4S//gC6NY42zS5E8KtC+1k25HW8wxvxdjs2KeJ9ozrd"
        • Sz6uOGJ/Zno4Nort6Fz1oS+qERjZ15gRvftCdvnrijKuI6P6af80E7Bonk3tdTFR
        • 7J0gj2k/5/a9RBA2VvqjIMNEuLO5nx8QBIC6um4nT8FvsLLR0mDgFYf3SqJSzpiY
          retrieval_mode: multiple
          multiple_retrieval_config:
          top_k: 5
          reranking_enable: true
          reranking_mode: reranking_model
          reranking_model:
          provider: langgenius/tongyi/tongyi
          model: gte-rerank-v2
          id: 'kr_2_doc_retrieval'
      • data:
        title: LLM 3 (答案生成)
        desc: 基于检索到的文档片段,生成回答。
        type: llm
        model:
        provider: langgenius/tongyi/tongyi
        name: qwen-plus
        mode: chat
        completion_params: {}
        prompt_template:
        • role: system
          text: '你是一个上海市教育招生领域的问答专家。请根据下面提供的【背景知识】,用清晰、准确、专业的语言回答用户的【问题】。禁止回答【背景知识】中没有提到的内容。'
        • role: user
          text: '【背景知识】:\n{{#kr_2_doc_retrieval.result#}}\n\n---\n\n【问题】:\n{{#llm_1_query_rewrite.text#}}'
          context:
          enabled: true
          variable_selector:
          • 'kr_2_doc_retrieval'
          • result
            id: 'llm_3_generate_answer'
      • data:
        title: 代码执行 2 (最终格式化)
        desc: "提取URL并与生成的答案拼接成最终格式"
        type: code
        code_language: python3
        variables:
        • variable: generated_answer
          value_selector:
          • 'llm_3_generate_answer'
          • text
        • variable: retrieved_docs
          value_selector:
          • 'kr_2_doc_retrieval'

          • result
            outputs:
            final_output:
            type: string
            code: |
            def main(generated_answer: str, retrieved_docs: list) -> dict:
            urls = []
            seen_urls = set()
            for doc in retrieved_docs:
            try:
            url = doc.get('metadata', {}).get('doc_metadata', {}).get('original_url')
            if url and url not in seen_urls:
            urls.append(url)
            seen_urls.add(url)
            except:
            pass

            final_text = generated_answer
            if urls:
            url_string = "\n".join(urls)
            final_text += f"\n\n参考链接:\n{url_string}"

            return {"final_output": final_text}
            id: 'code_2_format_final_output'

      • data:
        title: 直接回复 2 (最终答案)
        type: answer
        answer: '{{#code_2_format_final_output.final_output#}}'
        id: 'answer_2_final'

✔️ Expected Behavior

Succeed

Actual Behavior

Image Image
Originally created by @mengze1320 on GitHub (Jul 24, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.5.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Here is the yml file: app: description: '' icon: 🤖 icon_background: '#FFEAD5' mode: advanced-chat name: 招生问答网页版 (优化版) use_icon_as_answer_icon: false dependencies: - current_identifier: null type: marketplace value: marketplace_plugin_unique_identifier: langgenius/tongyi:0.0.27@4bb3f3eb6149b01f92aa6038a6bb074cc4224b8c015f54c888e5c5a30fc1ab50 kind: app version: 0.3.0 workflow: conversation_variables: - description: '' id: 0a7bd6e8-3c5f-4cf8-a075-1dbe144253e7 name: exam_type selector: - conversation - exam_type value: '' value_type: string - description: '' id: dd3e134a-3905-49d1-96c3-b8cdf084aaac name: time selector: - conversation - time value: 2025 value_type: number - description: 用于存储用户历史输入数据 id: e8f0d784-a4ac-4515-84a0-4d632687be46 name: conversation_histories selector: - conversation - conversation_histories value: [] value_type: array[string] environment_variables: [] features: file_upload: enabled: false opening_statement: '' retriever_resource: enabled: true sensitive_word_avoidance: enabled: false speech_to_text: enabled: false suggested_questions: [] suggested_questions_after_answer: enabled: false text_to_speech: enabled: false graph: edges: - data: {} id: start-llm2 source: 'start' sourceHandle: source target: 'llm_2_intent_check' targetHandle: target - data: {} id: llm2-if1 source: 'llm_2_intent_check' sourceHandle: source target: 'if_else_1_is_complete' targetHandle: target - data: {} id: if1_true-llm1 source: 'if_else_1_is_complete' sourceHandle: case_is_complete target: 'llm_1_query_rewrite' targetHandle: target - data: {} id: if1_false-answer_clarify source: 'if_else_1_is_complete' sourceHandle: 'false' target: 'answer_clarify_question' targetHandle: target - data: {} id: answer_clarify-assigner source: 'answer_clarify_question' sourceHandle: source target: 'assigner_1_store_history' targetHandle: target - data: {} id: if1_true-llm4 source: 'if_else_1_is_complete' sourceHandle: case_is_complete target: 'llm_4_extract_vars' targetHandle: target - data: {} id: llm4-assigner2 source: 'llm_4_extract_vars' sourceHandle: source target: 'assigner_2_store_vars' targetHandle: target - data: {} id: llm1-kr1 source: 'llm_1_query_rewrite' sourceHandle: source target: 'kr_1_qna_retrieval' targetHandle: target - data: {} id: kr1-if2 source: 'kr_1_qna_retrieval' sourceHandle: source target: 'if_else_2_is_kr1_found' targetHandle: target - data: {} id: if2_true-code1 source: 'if_else_2_is_kr1_found' sourceHandle: 'true' target: 'code_1_extract_qna_answer' targetHandle: target - data: {} id: code1-answer1 source: 'code_1_extract_qna_answer' sourceHandle: source target: 'answer_1_qna' targetHandle: target - data: {} id: if2_false-kr2 source: 'if_else_2_is_kr1_found' sourceHandle: 'false' target: 'kr_2_doc_retrieval' targetHandle: target - data: {} id: kr2-llm3 source: 'kr_2_doc_retrieval' sourceHandle: source target: 'llm_3_generate_answer' targetHandle: target - data: {} id: llm3-code2 source: 'llm_3_generate_answer' sourceHandle: source target: 'code_2_format_final_output' targetHandle: target - data: {} id: kr2-code2 source: 'kr_2_doc_retrieval' sourceHandle: source target: 'code_2_format_final_output' targetHandle: target - data: {} id: code2-answer2 source: 'code_2_format_final_output' sourceHandle: source target: 'answer_2_final' targetHandle: target nodes: - data: title: 开始 type: start id: 'start' - data: title: LLM 2 (需求分析引擎) desc: 判断用户意图是否完整,输出 'Completed' 或 'Incompleted' 状态。 type: llm model: provider: langgenius/tongyi/tongyi name: qwen-plus mode: chat completion_params: {} prompt_template: - role: system text: "# 角色 你是一个专业的上海市教育政策咨询专家,同时也是一个高效的需求分析引擎。\n# 核心目标 你的唯一目标是分析用户输入和完整的对话历史,判断用户的核心诉求是否清晰,并通过一轮或多轮对话,最终明确用户的完整意图。\n\n#完整意图必要的信息清单\n-具体是什么考试类型:可能包括但不限于高考,中考,研究生考试、成人考试、同等学力考试,自学考试,证书考试\n-用户咨询的主题:可能包括命题、报名、考试、评卷、成绩、志愿填报、招生录取、个性化咨询等等\n-时间信息:哪一年的考试\n\n#工作流程与逻辑\n你必须像一个程序一样,严格遵循以下步骤:\n 1. **分析上下文**: 首先,仔细检查完整的【对话历史】和用户的【最新输入】。 2. **核对清单**: 根据分析结果,判断上述“信息清单”中的三要素哪些已经明确,哪些仍然缺失。 \n3. **判断状态**: - 如果所有要素都已明确,当前状态为 **\"Completed\"**。 - 如果任一要素缺失,当前状态为 **\"Incompleted\"**。 \n4. **执行动作**: \n- 若状态为 **\"Incompleted\"**,请针对**最关键的缺失信息**,生成一句自然的、引导性的问题。\n - 若状态为 **\"Completed\"**,请将已收集到的所有用户需求原话进行输出。\n\n# 关键规则 \n- **记忆能力**: 你必须时刻检查【对话历史】,绝对不要重复提问用户已经给过的信息。\n- **自然对话**: 你的提问要像一个真人专家,友好且自然。\n - **禁止泄露背景知识**: 在“信息清单”中用于辅助你理解的考试分类(如春季高考、秋季高考、中考...)和主题分类(如命题、报名...),**绝对不能**以列表形式直接展示给用户。这些仅供你内部判断使用。\n- **严格的输出格式**: 你的最终输出必须,也只能是一个JSON对象,不能包含任何额外的文字、解释或Markdown标记。\n\n# 输出格式\n你必须严格按照以下JSON格式输出,不要有任何多余的文字或解释。\n-如果信息完整,则status为Completed,并且将组合的用户咨询需求原话输出到content中\n{\"status\":\"Completed\",\n\"content\":[具体的用户咨询内容]}\n-如果信息不完整,则status为Incompleted,请自然地询问缺失的信息并且将问题输出到content中\n{\"status\":\"Incompleted\",\n\"content\":[下一个引导性提问]}" - role: user text: '用户的输入{{#sys.query#}}\n\n对话历史:{{#conversation.conversation_histories#}}' structured_output_enabled: true structured_output: schema: type: object properties: status: type: string description: "该字段用于表示用户咨询是否清晰明确,'Completed'或'Incompleted'" content: type: string description: "该字段用于输出大模型的引导性提问或者整理好的用户提问" id: 'llm_2_intent_check' - data: title: 条件分支 1 desc: "判断用户意图是否完整" type: if-else cases: - case_id: case_is_complete conditions: - variable_selector: - 'llm_2_intent_check' - structured_output - status comparison_operator: is value: Completed id: 'if_else_1_is_complete' - data: title: 直接回复 (追问) type: answer answer: '{{#llm_2_intent_check.structured_output.content#}}' id: 'answer_clarify_question' - data: title: 变量赋值 1 desc: "将当前用户提问存入历史记录" type: assigner items: - variable_selector: - conversation - conversation_histories operation: append input_type: variable value: - sys - query id: 'assigner_1_store_history' - data: title: LLM 1 (查询重写引擎) desc: 将零散对话转换成独立的、完整的、用于检索的正式问题。 type: llm model: provider: langgenius/tongyi/tongyi name: qwen-plus mode: chat completion_params: {} prompt_template: - role: system text: "# 角色 你是一个专业的“查询重写”引擎,专门负责处理上海市教育招生考试领域的咨询。 \n# 核心目标 你的唯一任务是将用户在多轮对话中表达的、可能零散的意图,转换成一个**独立的、语法完整的、可以直接用于数据库检索的正式问题**。 \n# 关键规则 \n1. **转换而非描述**: 你的输出**必须**是一个完整的问句,而不是一句描述用户意图的话(例如,严禁使用“用户想了解...”这样的句式)。 \n2. **信息融合**: 你需要将对话中收集到的所有关键信息(如考试类型、年份、主题等)融合进这个最终的问句中。 \n3. **保持意图**: 转换后的问题必须100%忠实于用户的原始意图,且必须要保持用户的原话,且保持用户的原始句式,保持原话,保持原话。 \n4.**忠于事实**: 重写后的问题不能凭空捏造或添加原对话中不存在的事实信息。\n5. **参考风格**: 下面的例子展示了你输出的最终风格,你应该模仿这种**自包含(self-contained)**的问句格式。 \n# 转换后的用户咨询内容举例(输出风格参考):\n - \"2025年本市高中阶段学校招生的录取总成绩由哪些考试科目构成?\" \n - \"2024年上海市初中学业水平考试的科目有哪些?分值是怎样设置的?\"\n - \"如何申请2025年硕士研究生招生考试的成绩复核?\" \n- \"普通高校专升本的报名条件和流程是什么?\"" - role: user text: '{{#llm_2_intent_check.structured_output.content#}}' id: 'llm_1_query_rewrite' - data: title: LLM 4 (信息提取) desc: 从重写后的问题中提取年份和考试类型。 type: llm model: provider: langgenius/tongyi/tongyi name: qwen-plus mode: chat completion_params: {} prompt_template: - role: system text: "# 角色\n你是一个专门从文本中提取结构化信息的AI引擎。\n\n# 核心任务\n你的任务是仔细分析【用户查询】的文本,并从中提取出【时间信息】和【考试业务类型】这两个关键字段。然后,你必须严格按照预定义的JSON格式输出结果。\n\n# 字段提取规则\n1. **time (number)**:\n - 如果文本中包含明确的四位数年份(如‘2025年’、‘2024’),请提取该年份并以【数字】格式输出。\n - 如果文本中没有明确的年份,但提到了“今年”、“明年”等相对时间,请统一输出【当前年份的四位数字】,例如 `2025`。\n - 如果文本完全不涉及时间信息,请按照2025年进行处理。\n\n2. **exam_type (string)**:\n - 根据文本内容,判断其涉及的核心考试业务类型。\n - 你的判断应该基于一个预定义的分类(高考学考、中考招考、证书考试、自学考试、研考成考),但你只需要输出最终判断出的那个【字符串】结果。\n - 如果无法从文本中判断出具体的考试类型,请输出 `null`。\n\n# 输出格式\n你的输出**必须**是一个严格的、不包含任何额外解释或Markdown标记的JSON对象。\n\n# 示例\n---\n**用户查询**: \"2024年上海市的自学考试报名流程。\"\n**你的输出**:\n{\n \"time\": 2024,\n \"exam_type\": \"自学考试\"\n}\n---\n**用户查询**: \"中考的体育考试总分是多少?\"\n**你的输出**:\n{\n \"time\": 2025,\n \"exam_type\": \"中考\"\n}\n---\n\n**用户查询**: \"你好\"\n**你的输出**:\n{\n \"time\": null,\n \"exam_type\": null\n}\n---" - role: user text: '用户查询:{{#llm_1_query_rewrite.text#}}' structured_output_enabled: true structured_output: schema: type: object properties: time: type: number exam_type: type: string id: 'llm_4_extract_vars' - data: title: 变量赋值 2 desc: "存储提取出的年份和考试类型" type: assigner items: - variable_selector: - conversation - time operation: over-write input_type: variable value: - 'llm_4_extract_vars' - structured_output - time - variable_selector: - conversation - exam_type operation: over-write input_type: variable value: - 'llm_4_extract_vars' - structured_output - exam_type id: 'assigner_2_store_vars' - data: title: 知识检索 1 (Q&A) desc: 第一层,高精度检索问答对知识库。 type: knowledge-retrieval query_variable_selector: - 'llm_1_query_rewrite' - text dataset_ids: - cZUBZkC6zX4mN2T5LblosITl8SacjJD83sjq+rY+6xhWroBv43BCTaMPv/d6a8pN retrieval_mode: multiple multiple_retrieval_config: top_k: 1 score_threshold: 0.8 reranking_enable: false id: 'kr_1_qna_retrieval' - data: title: 条件分支 2 desc: 判断第一层知识检索是否命中。 type: if-else cases: - case_id: 'true' conditions: - variable_selector: - 'kr_1_qna_retrieval' - result comparison_operator: not empty id: 'if_else_2_is_kr1_found' - data: title: 代码执行 1 desc: "从元数据中提取预设的标准答案" type: code code_language: python3 variables: - variable: qna_result value_selector: - 'kr_1_qna_retrieval' - result outputs: answer: type: string code: | def main(qna_result: list) -> dict: if not qna_result: return {"answer": "抱歉,没有找到直接答案。"} return { "answer": qna_result[0].get('metadata', {}).get('doc_metadata', {}).get('answer', '未找到预设答案。') } id: 'code_1_extract_qna_answer' - data: title: 直接回复 1 (标准答案) type: answer answer: '{{#code_1_extract_qna_answer.answer#}}' id: 'answer_1_qna' - data: title: 知识检索 2 (文档) desc: 第二层,检索长文档知识库。 type: knowledge-retrieval query_variable_selector: - 'llm_1_query_rewrite' - text dataset_ids: - mf3VS+yBGgWEFi1Ml+68wO/UlSH7iwUJ4mu/wLFG5lrs98hd8x8qKivgzbf9jQDP - "+JNSzYIb5ChVBeFPdNLuj4S//gC6NY42zS5E8KtC+1k25HW8wxvxdjs2KeJ9ozrd" - Sz6uOGJ/Zno4Nort6Fz1oS+qERjZ15gRvftCdvnrijKuI6P6af80E7Bonk3tdTFR - 7J0gj2k/5/a9RBA2VvqjIMNEuLO5nx8QBIC6um4nT8FvsLLR0mDgFYf3SqJSzpiY retrieval_mode: multiple multiple_retrieval_config: top_k: 5 reranking_enable: true reranking_mode: reranking_model reranking_model: provider: langgenius/tongyi/tongyi model: gte-rerank-v2 id: 'kr_2_doc_retrieval' - data: title: LLM 3 (答案生成) desc: 基于检索到的文档片段,生成回答。 type: llm model: provider: langgenius/tongyi/tongyi name: qwen-plus mode: chat completion_params: {} prompt_template: - role: system text: '你是一个上海市教育招生领域的问答专家。请根据下面提供的【背景知识】,用清晰、准确、专业的语言回答用户的【问题】。禁止回答【背景知识】中没有提到的内容。' - role: user text: '【背景知识】:\n{{#kr_2_doc_retrieval.result#}}\n\n---\n\n【问题】:\n{{#llm_1_query_rewrite.text#}}' context: enabled: true variable_selector: - 'kr_2_doc_retrieval' - result id: 'llm_3_generate_answer' - data: title: 代码执行 2 (最终格式化) desc: "提取URL并与生成的答案拼接成最终格式" type: code code_language: python3 variables: - variable: generated_answer value_selector: - 'llm_3_generate_answer' - text - variable: retrieved_docs value_selector: - 'kr_2_doc_retrieval' - result outputs: final_output: type: string code: | def main(generated_answer: str, retrieved_docs: list) -> dict: urls = [] seen_urls = set() for doc in retrieved_docs: try: url = doc.get('metadata', {}).get('doc_metadata', {}).get('original_url') if url and url not in seen_urls: urls.append(url) seen_urls.add(url) except: pass final_text = generated_answer if urls: url_string = "\\n".join(urls) final_text += f"\\n\\n参考链接:\\n{url_string}" return {"final_output": final_text} id: 'code_2_format_final_output' - data: title: 直接回复 2 (最终答案) type: answer answer: '{{#code_2_format_final_output.final_output#}}' id: 'answer_2_final' ### ✔️ Expected Behavior Succeed ### ❌ Actual Behavior <img width="1163" height="157" alt="Image" src="https://github.com/user-attachments/assets/5f1dab6a-a179-459e-9de4-3db72d1b3d7a" /> <img width="1357" height="411" alt="Image" src="https://github.com/user-attachments/assets/c7ab846a-1d67-4e88-b9fe-9b03dc10b03a" />
yindo added the 🤔 cant-reproduce label 2026-02-21 19:22:44 -05:00
yindo closed this issue 2026-02-21 19:22:44 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jul 24, 2025):

This error usually means the import logic is trying to access the .length property of something that's actually undefined, most likely an array or string field in your YAML. Based on the code and recent changes to DSL import, this often happens if a required array field is missing or set to null instead of an empty array ([]) in your YAML file. For example, fields like environment_variables, suggested_questions, or any other array-type property must be present and set to [] if you don't have values for them—do not omit them or set them to null [source].

Try double-checking your YAML for any missing array fields and ensure they're explicitly set to []. This should help avoid the Cannot read properties of undefined (reading 'length') error during import. If the problem persists, it may be due to a bug in the frontend import logic that doesn't handle missing fields gracefully, as recent PRs have changed how DSL imports are processed [source][source].

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Jul 24, 2025): <!-- Answer --> This error usually means the import logic is trying to access the `.length` property of something that's actually `undefined`, most likely an array or string field in your YAML. Based on the code and recent changes to DSL import, this often happens if a required array field is missing or set to `null` instead of an empty array (`[]`) in your YAML file. For example, fields like `environment_variables`, `suggested_questions`, or any other array-type property must be present and set to `[]` if you don't have values for them—do not omit them or set them to `null` [[source](https://github.com/langgenius/dify/blob/32df3b68c79594b871d5aa203579355e85e035b0/web/app/components/app/create-from-dsl-modal/index.tsx)]. Try double-checking your YAML for any missing array fields and ensure they're explicitly set to `[]`. This should help avoid the `Cannot read properties of undefined (reading 'length')` error during import. If the problem persists, it may be due to a bug in the frontend import logic that doesn't handle missing fields gracefully, as recent PRs have changed how DSL imports are processed [[source](https://github.com/langgenius/dify/pull/20706)][[source](https://github.com/langgenius/dify/pull/20757)]. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/51476fa5-85ac-425e-aae5-c3d21de28f06?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/51476fa5-85ac-425e-aae5-c3d21de28f06?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/51476fa5-85ac-425e-aae5-c3d21de28f06?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/51476fa5-85ac-425e-aae5-c3d21de28f06?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/51476fa5-85ac-425e-aae5-c3d21de28f06?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/51476fa5-85ac-425e-aae5-c3d21de28f06?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/51476fa5-85ac-425e-aae5-c3d21de28f06?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/22941)
Author
Owner

@HyaCiovo commented on GitHub (Jul 24, 2025):

Could you upload your yaml file

@HyaCiovo commented on GitHub (Jul 24, 2025): Could you upload your yaml file
Author
Owner

@mengze1320 commented on GitHub (Jul 24, 2025):

Could you upload your yaml file

qa.zip

@mengze1320 commented on GitHub (Jul 24, 2025): > Could you upload your yaml file [qa.zip](https://github.com/user-attachments/files/21422194/qa.zip)
Author
Owner

@HyaCiovo commented on GitHub (Jul 24, 2025):

Image

In your DSL, the start node is missing the variables field. I tried exporting an empty workflow's DSL and it still includes variables: [].

Image
@HyaCiovo commented on GitHub (Jul 24, 2025): <img width="611" height="179" alt="Image" src="https://github.com/user-attachments/assets/14f31798-e0f6-49a1-b508-1abc65639c46" /> In your DSL, the start node is missing the `variables` field. I tried exporting an empty workflow's DSL and it still includes `variables: []`. <img width="537" height="241" alt="Image" src="https://github.com/user-attachments/assets/edc9fefc-d58c-48e7-a972-260e881e550c" />
Author
Owner

@HyaCiovo commented on GitHub (Jul 24, 2025):

Additionally, I found that your DSL is missing the condition.id field for the condition branch node, which is quite strange.

Image
@HyaCiovo commented on GitHub (Jul 24, 2025): Additionally, I found that your DSL is missing the condition.id field for the condition branch node, which is quite strange. <img width="1077" height="573" alt="Image" src="https://github.com/user-attachments/assets/4ea604bd-2b6e-4e99-89c4-138be153a03e" />
Author
Owner

@HyaCiovo commented on GitHub (Jul 25, 2025):

Is your DSL exported directly from the Dify platform? I found that it's missing so many fields.

@HyaCiovo commented on GitHub (Jul 25, 2025): Is your DSL exported directly from the Dify platform? I found that it's missing so many fields.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#15655