Modifying body in langfuse_filter_pipeline Causes 400 Bad Request Errors in Open-WebUI #137

Open
opened 2026-02-15 19:16:13 -05:00 by yindo · 1 comment
Owner

Originally created by @mcdorians on GitHub (Oct 6, 2024).

Issue Summary

When using the langfuse_filter_pipeline in Open-WebUI, modifying the part where the body dictionary gets extended with chat_id within the inlet or outlet methods causes a 400 Bad Request error from the downstream API (https://<openai_api_url>/chat/completions). As a result, non-streamed completions like tool requests fail and are ignored because the completions fails..

Steps to Reproduce

  1. Install and activate the langfuse_filter_pipeline.py in Open-WebUI.
  2. Use a tool that triggers a non-streamed completion (e.g., a tool request).
  3. Observe that a 400 Bad Request error occurs in the Open-WebUI logs.
  4. The tool does not function as expected due to this error.

Code Causing the Issue

The following code in langfuse_filter_pipeline.py appears to cause the error:

if "chat_id" not in body:
    unique_id = f"SYSTEM MESSAGE {uuid.uuid4()}"
    body["chat_id"] = unique_id
    print(f"chat_id was missing, set to: {unique_id}")

Even adding any arbitrary key to body every time, such as:

body["my_stupid_test"] = "bla" # in this case every completion request will lead to 400

leads to the same 400 Bad Request error.

Observed Behavior

  • When chat_id is not set (which is common with non-streamed completions like tool requests), modifying the body in the filter results in a 400 Bad Request error from the downstream API.
  • The tools are ignored because the requests fail.
  • Skipping the modification of body avoids the error but may not be ideal for logging purposes.

Expected Behavior

  • Modifying the body within the filter should not cause a 400 Bad Request error.
  • Non-streamed completions and tool requests should function correctly even when body is modified for logging or tracking purposes.

Question

  • Is modifying the body in the filter pipeline not allowed?
  • Is this behavior expected, or is it a bug in the pipelines framework?
  • How can we log necessary information using the filter without causing downstream API errors?

Logs

ERROR [open_webui.main] Error: 400: External: 400, message='Bad Request', url='https://<url>/chat/completions'

Additional Information

  • The issue consistently occurs whenever the body is modified in the filter.
  • Skipping the modification (e.g., by returning early if chat_id is not present) prevents the error but also skips necessary logging.
if not body.get("chat_id"):
      print("Skipping inlet processing because no chat_id.")
      return body

Request

Please investigate this issue. It seems that modifying the body in the langfuse_filter_pipeline causes downstream API requests to fail with a 400 Bad Request error.

Originally created by @mcdorians on GitHub (Oct 6, 2024). **Issue Summary** When using the `langfuse_filter_pipeline` in Open-WebUI, modifying the part where the `body` dictionary gets extended with `chat_id` within the `inlet` or `outlet` methods causes a `400 Bad Request` error from the downstream API (`https://<openai_api_url>/chat/completions`). As a result, non-streamed completions like tool requests fail and are ignored because the completions fails.. **Steps to Reproduce** 1. Install and activate the `langfuse_filter_pipeline.py` in Open-WebUI. 2. Use a tool that triggers a non-streamed completion (e.g., a tool request). 3. Observe that a `400 Bad Request` error occurs in the Open-WebUI logs. 4. The tool does not function as expected due to this error. **Code Causing the Issue** The following code in `langfuse_filter_pipeline.py` appears to cause the error: ```python if "chat_id" not in body: unique_id = f"SYSTEM MESSAGE {uuid.uuid4()}" body["chat_id"] = unique_id print(f"chat_id was missing, set to: {unique_id}") ``` Even adding any arbitrary key to `body` every time, such as: ```python body["my_stupid_test"] = "bla" # in this case every completion request will lead to 400 ``` leads to the same `400 Bad Request` error. **Observed Behavior** - When `chat_id` is not set (which is common with non-streamed completions like tool requests), modifying the `body` in the filter results in a `400 Bad Request` error from the downstream API. - The tools are ignored because the requests fail. - Skipping the modification of `body` avoids the error but may not be ideal for logging purposes. **Expected Behavior** - Modifying the `body` within the filter should not cause a `400 Bad Request` error. - Non-streamed completions and tool requests should function correctly even when `body` is modified for logging or tracking purposes. **Question** - Is modifying the `body` in the filter pipeline not allowed? - Is this behavior expected, or is it a bug in the pipelines framework? - How can we log necessary information using the filter without causing downstream API errors? **Logs** ``` ERROR [open_webui.main] Error: 400: External: 400, message='Bad Request', url='https://<url>/chat/completions' ``` **Additional Information** - The issue consistently occurs whenever the `body` is modified in the filter. - Skipping the modification (e.g., by returning early if `chat_id` is not present) prevents the error but also skips necessary logging. ```python if not body.get("chat_id"): print("Skipping inlet processing because no chat_id.") return body ``` **Request** Please investigate this issue. It seems that modifying the `body` in the `langfuse_filter_pipeline` causes downstream API requests to fail with a `400 Bad Request` error.
Author
Owner

@cspengler-plexxis commented on GitHub (Oct 16, 2024):

This happens in a custom pipeline I've written as well. It would be super useful to be able to add keys to the body dict within the filter (in my case, I want to append context retrieved by the RAG process in the inlet, and then access that context in the outlet so I can log it in a database along with all the other details of the user-assistant exchange).

@cspengler-plexxis commented on GitHub (Oct 16, 2024): This happens in a custom pipeline I've written as well. It would be super useful to be able to add keys to the body dict within the filter (in my case, I want to append context retrieved by the RAG process in the inlet, and then access that context in the outlet so I can log it in a database along with all the other details of the user-assistant exchange).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: open-webui/pipelines#137