Skip to content

TypeError: list indices must be integers or slices, not str when using Pipelines in v0.6.5 #511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
hirokawaguchi opened this issue Apr 21, 2025 · 1 comment

Comments

@hirokawaguchi
Copy link

Describe the bug
When attempting to use any pipeline (even a minimal one) via the /api/chat/completions endpoint, OpenWebUI v0.6.5 throws a TypeError: list indices must be integers or slices, not str. This results in a 400 Bad Request response, and the pipeline code itself is never executed. The error seems to occur within the main OpenWebUI backend code while processing the request before dispatching it to the pipeline server. Regular models (non-pipeline) work correctly.

To Reproduce

  1. Set up OpenWebUI v0.6.5 with the pipeline server enabled.
  2. Create a minimal pipeline file (e.g., hello.py in the pipelines directory) like the simplified one below:
    # pipelines/hello.py
    """
    name: Hello Simplified
    description: A minimal pipeline for testing.
    """
    from typing import List, Union, Generator, Iterator
    from pprint import pprint
    
    class Pipeline:
        def __init__(self):
            self.name: str = "Hello Simplified"
            self.debug: bool = True
    
        async def on_startup(self):
            print(f"[{self.name}] on_startup")
    
        async def on_shutdown(self):
            print(f"[{self.name}] on_shutdown")
    
        def pipe(
            self,
            user_message: str,
            model_id: str,
            messages: List[dict],
            body: Union[dict, list],
        ) -> Union[str, Generator, Iterator]:
            print(f"[{self.name}] pipe function called.") # This line is never reached
            pprint(user_message)
            pprint(model_id)
            pprint(messages)
            pprint(body)
            return f"Simplified Hello! You sent: {user_message}"
  3. Enable DEBUG logging for the main open-webui container (e.g., set GLOBAL_LOG_LEVEL=DEBUG in docker-compose.yaml).
  4. Restart OpenWebUI.
  5. In the Web UI, select the "Hello Simplified" pipeline as the model.
  6. Send any chat message (e.g., "Hello").
  7. Observe the 400 Bad Request error in the UI and the browser's network console.
  8. Check the logs for the main open-webui container.

Expected behavior
The /api/chat/completions request should succeed (return 200 OK), and the pipeline's pipe method should be called, processing the message and returning a response. The pipeline server logs should show the pipe function called. message.

Actual behavior
The request fails with a 400 Bad Request. The open-webui container log shows the following DEBUG messages just before the error, indicating the error occurs within the main backend when processing the chat payload for a pipeline model:

2025-04-21 07:38:54.543 | DEBUG    | open_webui.utils.middleware:process_chat_payload:688 - form_data: {'stream': True, 'model': 'hello', 'messages': [{'role': 'user', 'content': 'こんにちは'}], ... , 'model': {'id': 'hello', 'name': 'Hello Simplified', ... 'pipeline': {'type': 'pipe', ...}, ...}} - {}
2025-04-21 07:38:54.543 | DEBUG    | open_webui.main:chat_completion:1135 - Error processing chat payload: list indices must be integers or slices, not str - {}
2025-04-21 07:38:54.545 | INFO     | uvicorn.protocols.http.httptools_impl:send:476 - ... - "POST /api/chat/completions HTTP/1.1" 400 - {}

(Note: Some parts of the log like user ID, chat ID, full form_data details, etc., were truncated for brevity)

The pipeline server (open-webui-pipelines-1 container) logs show the on_startup message but never receive the request to execute the pipe method.

Environment details

  • OS: [docker(colima) on macOS Sonoma]
  • Browser: [Chrome 135.0.7049.96]
  • OpenWebUI Version: v0.6.5
  • Deployment method: Docker Compose

Additional context
This issue seems specific to the pipeline functionality introduced/updated around v0.6.x. Using standard LLMs (not pipelines) works correctly, and the /api/chat/completions endpoint returns a 200 OK status for them. The error occurs regardless of the complexity of the pipeline code itself.

@MichelDucartier
Copy link

In case if anyone stumbles on this, the issue seems to linked to this part in open-webui:

urlIdx = filter.get("urlIdx")
if urlIdx is None:
     continue

url = request.app.state.config.OPENAI_API_BASE_URLS[urlIdx]
key = request.app.state.config.OPENAI_API_KEYS[urlIdx]

urlIdx is a str and needs to be cast to int

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants