Bug in API /workflows/run #4832

Closed
opened 2026-02-21 18:08:12 -05:00 by yindo · 4 comments
Owner

Originally created by @amitshuklabag on GitHub (Jul 30, 2024).

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

main

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Use the Docker tag "main" to deploy a new application.

  2. Set up a new workflow as required by your application.

  3. API Request the /workflows/run API endpoint.
    API returns a response with the following error message: { "message": "Internal Server Error", "code": "unknown" }

  4. Log Error Details: The logs show the following error trace:

app-api-1         | 2024-07-30 14:14:49,236.236 ERROR [Dummy-27] [app.py:838] - Exception on /v1/workflows/run [GET]
app-api-1         | Traceback (most recent call last):
app-api-1         |   File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request
app-api-1         |     rv = self.dispatch_request()
app-api-1         |   File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 865, in dispatch_request
app-api-1         |     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
app-api-1         |   File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 489, in wrapper
app-api-1         |     resp = resource(*args, **kwargs)
app-api-1         |   File "/app/api/.venv/lib/python3.10/site-packages/flask/views.py", line 110, in view
app-api-1         |     return current_app.ensure_sync(self.dispatch_request)(**kwargs)  # type: ignore[no-any-return]
app-api-1         |   File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 604, in dispatch_request
app-api-1         |     resp = meth(*args, **kwargs)
app-api-1         |   File "/app/api/controllers/service_api/wraps.py", line 75, in decorated_view
app-api-1         |     return view_func(*args, **kwargs)
app-api-1         |   File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 696, in wrapper
app-api-1         |     resp = f(*args, **kwargs)
app-api-1         | TypeError: WorkflowRunApi.get() missing 1 required positional argument: 'workflow_id'

Note: According to the documentation, the workflow_id parameter is not required when calling the API. Instead, it should be returned in the response. This discrepancy suggests that there might be an issue with how the API is handling requests or responses.

✔️ Expected Behavior

Response from the API based on the doc.

Actual Behavior

{
"message": "Internal Server Error",
"code": "unknown"
}

Originally created by @amitshuklabag on GitHub (Jul 30, 2024). ### 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 main ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1. Use the Docker tag "main" to deploy a new application. 2. Set up a new workflow as required by your application. 3. API Request the /workflows/run API endpoint. API returns a response with the following error message: `{ "message": "Internal Server Error", "code": "unknown" } ` 4. Log Error Details: The logs show the following error trace: ``` app-api-1 | 2024-07-30 14:14:49,236.236 ERROR [Dummy-27] [app.py:838] - Exception on /v1/workflows/run [GET] app-api-1 | Traceback (most recent call last): app-api-1 | File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request app-api-1 | rv = self.dispatch_request() app-api-1 | File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 865, in dispatch_request app-api-1 | return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] app-api-1 | File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 489, in wrapper app-api-1 | resp = resource(*args, **kwargs) app-api-1 | File "/app/api/.venv/lib/python3.10/site-packages/flask/views.py", line 110, in view app-api-1 | return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return] app-api-1 | File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 604, in dispatch_request app-api-1 | resp = meth(*args, **kwargs) app-api-1 | File "/app/api/controllers/service_api/wraps.py", line 75, in decorated_view app-api-1 | return view_func(*args, **kwargs) app-api-1 | File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 696, in wrapper app-api-1 | resp = f(*args, **kwargs) app-api-1 | TypeError: WorkflowRunApi.get() missing 1 required positional argument: 'workflow_id' ``` **Note**: According to the documentation, the `workflow_id` parameter is not required when calling the API. Instead, it should be returned in the response. This discrepancy suggests that there might be an issue with how the API is handling requests or responses. ### ✔️ Expected Behavior Response from the API based on the doc. ### ❌ Actual Behavior { "message": "Internal Server Error", "code": "unknown" }
yindo added the 🐞 bug label 2026-02-21 18:08:12 -05:00
yindo closed this issue 2026-02-21 18:08:12 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jul 30, 2024):

Hello @amitshuklabag! I'm here to help you with any bugs, questions, or contributions you may have. Let's work together to resolve any issues you're facing.

To resolve the TypeError: WorkflowRunApi.get() missing 1 required positional argument: 'workflow_id' error when making a request to the /workflows/run endpoint, ensure you are using the correct HTTP method and providing the required parameters in your request.

The WorkflowRunApi class expects a POST request with specific parameters. Here is an example of how you should structure your request:

POST /workflows/run
Content-Type: application/json

{
    "inputs": {
        // your input data here
    },
    "files": [
        // your files data here, if any
    ],
    "response_mode": "blocking" // or "streaming"
}

Make sure you are passing the correct parameters in the JSON body of your request to avoid the TypeError. The inputs field is required and must be a dictionary, while the files field is optional and should be a list if provided. Additionally, you can specify the response_mode field to indicate whether you want a blocking or streaming response [1][2][3].

Also, ensure that the API-Key is included in the Authorization HTTP Header for all API requests:

Authorization: Bearer {API_KEY}

Example cURL request:

curl -X POST '${props.appDetail.api_base_url}/workflows/run' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "inputs": {},
    "response_mode": "streaming",
    "user": "abc-123"
}'

Additionally, ensure that the necessary environment variables are set correctly for your self-hosted deployment:

  • CONSOLE_API_URL
  • CONSOLE_WEB_URL
  • SERVICE_API_URL
  • APP_API_URL
  • APP_WEB_URL
  • FILES_URL

These configurations are crucial for the /workflows/run endpoint to function properly [4][5].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Jul 30, 2024): <!-- Greeting --> Hello @amitshuklabag! I'm here to help you with any bugs, questions, or contributions you may have. Let's work together to resolve any issues you're facing. <!-- Answer --> To resolve the `TypeError: WorkflowRunApi.get() missing 1 required positional argument: 'workflow_id'` error when making a request to the `/workflows/run` endpoint, ensure you are using the correct HTTP method and providing the required parameters in your request. The `WorkflowRunApi` class expects a `POST` request with specific parameters. Here is an example of how you should structure your request: ```http POST /workflows/run Content-Type: application/json { "inputs": { // your input data here }, "files": [ // your files data here, if any ], "response_mode": "blocking" // or "streaming" } ``` Make sure you are passing the correct parameters in the JSON body of your request to avoid the `TypeError`. The `inputs` field is required and must be a dictionary, while the `files` field is optional and should be a list if provided. Additionally, you can specify the `response_mode` field to indicate whether you want a blocking or streaming response <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/controllers/console/app/workflow_run.py)</sup><sup>[[2]](https://github.com/langgenius/dify/blob/main/api/controllers/web/workflow.py)</sup><sup>[[3]](https://github.com/langgenius/dify/blob/main/api/controllers/service_api/app/workflow.py)</sup>. Also, ensure that the `API-Key` is included in the `Authorization` HTTP Header for all API requests: ```javascript Authorization: Bearer {API_KEY} ``` Example cURL request: ```bash curl -X POST '${props.appDetail.api_base_url}/workflows/run' \ --header 'Authorization: Bearer {api_key}' \ --header 'Content-Type: application/json' \ --data-raw '{ "inputs": {}, "response_mode": "streaming", "user": "abc-123" }' ``` Additionally, ensure that the necessary environment variables are set correctly for your self-hosted deployment: - `CONSOLE_API_URL` - `CONSOLE_WEB_URL` - `SERVICE_API_URL` - `APP_API_URL` - `APP_WEB_URL` - `FILES_URL` These configurations are crucial for the `/workflows/run` endpoint to function properly <sup>[[4]](https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template_workflow.en.mdx)</sup><sup>[[5]](https://github.com/langgenius/dify-docs/blob/main/en/getting-started/install-self-hosted/environments.md)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@amitshuklabag commented on GitHub (Jul 31, 2024):

Thanks for the quick fix; I appreciate it.

@amitshuklabag commented on GitHub (Jul 31, 2024): Thanks for the quick fix; I appreciate it.
Author
Owner

@smlHao commented on GitHub (Jul 31, 2024):

workflow_id

hi, How to pass the workflow_id parameter, i don`t find the workflow_id in url or request body

@smlHao commented on GitHub (Jul 31, 2024): > workflow_id hi, How to pass the workflow_id parameter, i don`t find the workflow_id in url or request body
Author
Owner

@smlHao commented on GitHub (Jul 31, 2024):

workflow_id

hi, How to pass the workflow_id parameter, i don`t find the workflow_id in url or request body

@amitshuklabag

@smlHao commented on GitHub (Jul 31, 2024): > > workflow_id > > hi, How to pass the workflow_id parameter, i don`t find the workflow_id in url or request body @amitshuklabag
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4832