Run failed: conversation variable not found in the database #10347

Closed
opened 2026-02-21 18:45:51 -05:00 by yindo · 0 comments
Owner

Originally created by @wrq9 on GitHub (Mar 11, 2025).

Self Checks

  • 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 (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

unknown

Cloud or Self Hosted

Cloud

Steps to reproduce

When I invoke my Chatflow (works correctly) via the API, the following error occurs:

Response: {'code': 'invalid_param', 'message': 'Run failed: conversation variable not found in the database', 'status': 400}

Python script:

import requests
import os
import mimetypes

def upload_file(api_key, file_path, user_id):

    if not os.path.exists(file_path):
        raise FileNotFoundError(f"文件 {file_path} 不存在")

    # 自动检测MIME类型
    mime_type, _ = mimetypes.guess_type(file_path)

    # 验证是否为支持的图片类型
    supported_types = {
        'video/mp4',
    }

    if mime_type not in supported_types:
        raise ValueError(f"不支持的文件类型: {mime_type}")

    # 组装请求
    url = 'http://dify-api-us-qa.eufylife.com/v1/files/upload'
    headers = {"Authorization": f"Bearer {api_key}"}

    try:
        with open(file_path, 'rb') as file:
            # 构建multipart表单数据
            files = {
                'file': (
                    os.path.basename(file_path),  # 文件名
                    file,  # 文件对象
                    mime_type  # MIME类型
                ),
                'user': (None, user_id)  # 文本字段
            }
            response = requests.post(
                url,
                headers=headers,
                files=files
            )
            response.raise_for_status()
            return response.json()

    except requests.exceptions.RequestException as e:
        print(f"请求失败: {str(e)}")
        return None

if __name__ == '__main__':
    url = "http://dify-api-us-qa.eufylife.com/v1/chat-messages"
    api_key = '...'
    file_path = '/Users/anker/Documents/爬.mp4'
    user_id = "..."
    response = upload_file(api_key, file_path, user_id)
    upload_file_id = response['id']
    print(f'Response: {response}')
    headers = {
        "Authorization": "Bearer {api_key}",
        "Content-Type": "application/json"
    }

    payload = {
        "inputs": {},
        "fix_questions": "视频中有几个人?\n视频中出现的人有什么特征?\n视频可以给予我们什么警示?",
        "query": "描述这段视频",
        "response_mode": "blocking",
        "conversation_id": "",
        "user": user_id,
        "files": [
            {
                "type": "video",
                "transfer_method": "remote_url",
                "url": "https://prod-streaming-video-msn-com.akamaized.net/a8c412fa-f696-4ff2-9c76-e8ed9cdffe0f/604a87fc-e7bc-463e-8d56-cde7e661d690.mp4"
                # "transfer_method": "local_file",
                # "upload_file_id": upload_file_id
            }
        ]
    }

    headers["Authorization"] = headers["Authorization"].format(api_key=api_key)

    response = requests.post(url, headers=headers, json=payload)

    print("Status Code:", response.status_code)
    if response.json().get('answer', None) is not None:
        print("Answer:", response.json()['answer'])
    else:
        print("Response:", response.json())

My Chatflow:

Image

✔️ Expected Behavior

No response

Actual Behavior

Response: {'code': 'invalid_param', 'message': 'Run failed: conversation variable not found in the database', 'status': 400}
Originally created by @wrq9 on GitHub (Mar 11, 2025). ### Self Checks - [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 (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version unknown ### Cloud or Self Hosted Cloud ### Steps to reproduce When I invoke my Chatflow (works correctly) via the API, the following error occurs: ``` Response: {'code': 'invalid_param', 'message': 'Run failed: conversation variable not found in the database', 'status': 400} ``` Python script: ``` import requests import os import mimetypes def upload_file(api_key, file_path, user_id): if not os.path.exists(file_path): raise FileNotFoundError(f"文件 {file_path} 不存在") # 自动检测MIME类型 mime_type, _ = mimetypes.guess_type(file_path) # 验证是否为支持的图片类型 supported_types = { 'video/mp4', } if mime_type not in supported_types: raise ValueError(f"不支持的文件类型: {mime_type}") # 组装请求 url = 'http://dify-api-us-qa.eufylife.com/v1/files/upload' headers = {"Authorization": f"Bearer {api_key}"} try: with open(file_path, 'rb') as file: # 构建multipart表单数据 files = { 'file': ( os.path.basename(file_path), # 文件名 file, # 文件对象 mime_type # MIME类型 ), 'user': (None, user_id) # 文本字段 } response = requests.post( url, headers=headers, files=files ) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: print(f"请求失败: {str(e)}") return None if __name__ == '__main__': url = "http://dify-api-us-qa.eufylife.com/v1/chat-messages" api_key = '...' file_path = '/Users/anker/Documents/爬.mp4' user_id = "..." response = upload_file(api_key, file_path, user_id) upload_file_id = response['id'] print(f'Response: {response}') headers = { "Authorization": "Bearer {api_key}", "Content-Type": "application/json" } payload = { "inputs": {}, "fix_questions": "视频中有几个人?\n视频中出现的人有什么特征?\n视频可以给予我们什么警示?", "query": "描述这段视频", "response_mode": "blocking", "conversation_id": "", "user": user_id, "files": [ { "type": "video", "transfer_method": "remote_url", "url": "https://prod-streaming-video-msn-com.akamaized.net/a8c412fa-f696-4ff2-9c76-e8ed9cdffe0f/604a87fc-e7bc-463e-8d56-cde7e661d690.mp4" # "transfer_method": "local_file", # "upload_file_id": upload_file_id } ] } headers["Authorization"] = headers["Authorization"].format(api_key=api_key) response = requests.post(url, headers=headers, json=payload) print("Status Code:", response.status_code) if response.json().get('answer', None) is not None: print("Answer:", response.json()['answer']) else: print("Response:", response.json()) ``` My Chatflow: ![Image](https://github.com/user-attachments/assets/c588b5ee-15ec-482b-a944-04cb9cee0543) ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior ``` Response: {'code': 'invalid_param', 'message': 'Run failed: conversation variable not found in the database', 'status': 400} ```
yindo added the 🐞 bug label 2026-02-21 18:45:51 -05:00
yindo closed this issue 2026-02-21 18:45:51 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#10347